I am using the following code to fetch records from a custom taxonomy.
if ($_GET['post_type'] == "developments"){ ?>
<?php
global $wp_query;
$paged = $wp_query->query_vars['paged'];
$development_args = array(
'post_type' => $_GET['post_type'],
'orderby' =>'title',
'order' => 'ASC',
'posts_per_page' => 14,
'paged' => $paged,
's' => $_GET['search_building_name'],
);
$development_args['meta_query'] = array(
'relation'=>'AND',
array(
'key' => 'total_units',
'type' => 'numeric',
'value' => $_GET['search_total_units'],
'compare' => $_GET['total_units_operator']
),
array(
'key' => 'total_floors',
'type' => 'numeric',
'value' => $_GET['search_total_floors'],
'compare' => $_GET['total_floors_operator']
),
);
$development_args['tax_query'] = array(
'relation' => 'AND',
array(
'taxonomy' => 'type',
'field' => 'slug',
'terms' => $_GET['search_type'],
//'operator' => 'AND'
),
array(
'taxonomy' => 'amenities',
'field' => 'slug',
'terms' => $_GET['search_amenities'],
'operator' => 'AND'
),
array(
'taxonomy' => 'style',
'field' => 'slug',
'terms' => $_GET['search_style'],
'operator' => 'AND'
),
);
if ($_GET['search_neighborhood'] != 'any'){
$development_args['tax_query'][] = array(
'taxonomy' => 'neighborhood',
'field' => 'slug',
'terms' => $_GET['search_neighborhood'],
);
}
if ($_GET['search_developer'] != 'any'){
$development_args['tax_query'][] = array(
'taxonomy' => 'developer',
'field' => 'slug',
'terms' => $_GET['search_developer'],
);
}
if ($_GET['search_architect'] != 'any'){
$development_args['tax_query'][] = array(
'taxonomy' => 'architect',
'field' => 'slug',
'terms' => $_GET['search_architect'],
);
}
if ($_GET['search_delivered'] != 'any'){
$development_args['tax_query'][] = array(
'taxonomy' => 'delivered',
'field' => 'slug',
'terms' => $_GET['search_delivered'],
);
}
query_posts($development_args );
}
$wp_query->post_count returns 10, even when the actual number of records is lot more. I have tried various solutions but none work for me. This question could be a duplicate but i am asking this again because even a few answers have worked for other people but none have given a good explanation. Thanks
I am using the following code to fetch records from a custom taxonomy.
if ($_GET['post_type'] == "developments"){ ?>
<?php
global $wp_query;
$paged = $wp_query->query_vars['paged'];
$development_args = array(
'post_type' => $_GET['post_type'],
'orderby' =>'title',
'order' => 'ASC',
'posts_per_page' => 14,
'paged' => $paged,
's' => $_GET['search_building_name'],
);
$development_args['meta_query'] = array(
'relation'=>'AND',
array(
'key' => 'total_units',
'type' => 'numeric',
'value' => $_GET['search_total_units'],
'compare' => $_GET['total_units_operator']
),
array(
'key' => 'total_floors',
'type' => 'numeric',
'value' => $_GET['search_total_floors'],
'compare' => $_GET['total_floors_operator']
),
);
$development_args['tax_query'] = array(
'relation' => 'AND',
array(
'taxonomy' => 'type',
'field' => 'slug',
'terms' => $_GET['search_type'],
//'operator' => 'AND'
),
array(
'taxonomy' => 'amenities',
'field' => 'slug',
'terms' => $_GET['search_amenities'],
'operator' => 'AND'
),
array(
'taxonomy' => 'style',
'field' => 'slug',
'terms' => $_GET['search_style'],
'operator' => 'AND'
),
);
if ($_GET['search_neighborhood'] != 'any'){
$development_args['tax_query'][] = array(
'taxonomy' => 'neighborhood',
'field' => 'slug',
'terms' => $_GET['search_neighborhood'],
);
}
if ($_GET['search_developer'] != 'any'){
$development_args['tax_query'][] = array(
'taxonomy' => 'developer',
'field' => 'slug',
'terms' => $_GET['search_developer'],
);
}
if ($_GET['search_architect'] != 'any'){
$development_args['tax_query'][] = array(
'taxonomy' => 'architect',
'field' => 'slug',
'terms' => $_GET['search_architect'],
);
}
if ($_GET['search_delivered'] != 'any'){
$development_args['tax_query'][] = array(
'taxonomy' => 'delivered',
'field' => 'slug',
'terms' => $_GET['search_delivered'],
);
}
query_posts($development_args );
}
$wp_query->post_count returns 10, even when the actual number of records is lot more. I have tried various solutions but none work for me. This question could be a duplicate but i am asking this again because even a few answers have worked for other people but none have given a good explanation. Thanks
Share Improve this question edited Jan 8, 2013 at 0:09 Lucky asked Jan 7, 2013 at 22:47 LuckyLucky 1 3 |1 Answer
Reset to default -1Try taking out the 'paged' => $paged
parameter, as it is simply returning the amount of results for that page, which seems to be set at 10.
(You will need to do two separate queries - one for getting the true count, and one for displaying the posts in a paginated format.)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744930885a4601730.html
query_posts
use a newWP_Object
instead andvar_dump
the object afterwards. You can see the actual SQL. Maybe that will give you a clue as to the problem. – s_ha_dum Commented Jan 7, 2013 at 23:09