• Hi guys,

    I’m using wp_query to get a list of custom posts of a single taxonomy.
    While I get the correct posts back, the $wp_query->max_num_pages value is incorrect (it returns the total number of pages based on the custom post type – without the taxonomy filter).

    You can see the code I’m using here : https://pastebin.com/NBDDma2q (nothing special really). Can anyone reproduce the problem ? Not sure if I’m doing something wrong or if this is an actual bug.

    Thanks,
    gNesher

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Try if the request is populated with the correct values:

    echo '<pre>';
    print_r($_REQUEST);
    echo '</pre>';

    and for pagination:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
    ///
    'paged' => $paged,

    Thread Starter gnesher

    (@gnesher)

    Hi Keesiemeijer,

    These are the arguments I’m using (simply used a print_r for the $args variable):

    Array
    (
        [post_type] => projects
        [paged] => 1
        [tax_query] => Array
            (
                [0] => Array
                    (
                        [taxonomy] => projectfilter
                        [field] => slug
                        [terms] => experiental
                    )
    
            )
    
    )

    This should be fine to the best of my knowledge

    Moderator keesiemeijer

    (@keesiemeijer)

    That should be fine. Maybe set the posts_per_page also in the $args array?

    Thread Starter gnesher

    (@gnesher)

    Doesn’t seem to help. Anyway the test taxonomies only have 1 posts each, it should return max_num_pages = 1 regardless.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wp_query returns wrong number of max pages’ is closed to new replies.