problem with max_num_pages
-
Hi,
I’m new to WordPress.
I’am having problems with a pagination I made.
Everything works fine if I show all the posts with this query:$args = array('posts_per_page' => 7, 'paged' => $current_page, 'post_type' => 'post', 'suppress_filters' => false); $postslist = get_posts( $args ); global $wp_query; $totalpages = $wp_query->max_num_pages;
In this case, the value of $totalpages = 94 which is correct.
However, the visitors should also be able to select that they only want to see the posts which belong to a certain category. In that case, I add category to the arguments array like this:
$args = array('posts_per_page' => 7, 'paged' => $current_page,'category' => $category_id, 'post_type' => 'post', 'suppress_filters' => false);
The posts of the correct category are shown correct on my page, however
`global $wp_query;
$totalpages = $wp_query->max_num_pages;
stills gives me the result 94 pages, which is not correct because 94 pages is the correct amount of pages for all categories.
Can someone explain me how I can find the total number of pages when I query the posts of 1 category?Thanks in advance
- The topic ‘problem with max_num_pages’ is closed to new replies.