I’m trying to set the number of posts displayed on an archive page using
$wp_query->query_vars["posts_per_page"] = 10;
This is exactly the same as
except that it doesn’t forget the other variables.
query_posts()ignores things like
paged, or which category you are browsing, meaning you have to check for them and set them again.
This works absolutely fine, displaying 10 posts per page, as I want it to, instead of 4, which is what I have in my settings. The problem arises when you get to the last page of posts, i.e. the page containing the earliest posts in the time period or category. There ought not to be a “previous posts” link, since there are none, but when I set
posts_per_pagemanually it is displayed regardless. Clicking on it takes you to an archive page without any posts, with a “previous posts” link too, which leads to yet another page without posts and so on.
I should point out that this happens regardless of how I set
posts_per_page, either by modifying the query array (the first method above) or by using
Has anyone encountered a similar problem, and if so how did they fix it? Or does anyone have any ideas about why this occurs?
- The topic ‘Previous posts link displayed even when there are no previous posts!’ is closed to new replies.