custom taxonomy - query posts returns 10 records

I am using the following code to fetch records from a custom taxonomy. if ($_GET['post_type'] == "develop

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 That is a lot of conditions. Are you sure there are more than 10? Tip: Don't use query_posts use a new WP_Object instead and var_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
  • yes i am sure that it has more than 10 – Lucky Commented Jan 7, 2013 at 23:24
  • Then try the debugging suggestion. It may help you spot why the query is returning the wrong count. – s_ha_dum Commented Jan 8, 2013 at 4:57
Add a comment  | 

1 Answer 1

Reset to default -1

Try 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

相关推荐

  • custom taxonomy - query posts returns 10 records

    I am using the following code to fetch records from a custom taxonomy. if ($_GET['post_type'] == "develop

    1天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信