Very very confused by a paging issue at the moment.
I have a page on a client site set to the blog page in the settings section. It can be viewed here:
As I don't want to show posts from certain categories on this page, I'm running a WP_query() to show only certain categories.
<?php $paged = get_query_var('paged'); global $query_string; $recentNews = new WP_query(); $recentNews->query($query_string . '&posts_per_page=4&cat=9,151&paged=' . $paged); if ($recentNews->have_posts()) : while ($recentNews->have_posts()) : $recentNews->the_post(); // Loop stuff then ?>
Using this method my paging only shows 2 pages of posts, even though I know there should be at least in the region of 20.
If I alter this to just do a standard query_posts such as:
$paged = get_query_var('paged'); global $query_string; query_posts($query_string . '&posts_per_page=4&cat=9,151&paged=' . $paged);
Then my paging shows 5 pages as existing, but as soon as you hit /page/3/ it gives a 404. http://bit.ly/aVUxpF
If I increase the number of posts_per_page then it shows more posts. For example, if I say posts_per_page=7, then it shows 7 posts on page 1, and 7 on page 2, but still page 3 returns a 404.
I've been going around in circles on this one and am giving up for the time being. I've read all sorts of forum posts and various articles, but none have sorted it :(
Would I be better off changing Settings/Reading/"Posts Page" and just creating a template page and running a custom query. Perhaps the fact that it's using index.php is causing confusion. It's an old old site that I first coded in my early days of WordPress, so that could be part of the issue..
Apologies for the bit.ly links, but as it's a client website I try to avoid anything that would risk returning this forum post as a search result.