I Fixed My Broken WordPress Pagination

wordpress pagination

Finally, I fixed my broken WordPress pagination. My theme uses the excellent wp-pagenavi from Lester Chan which has worked very well until recently. Despite my best efforts, I couldn’t find anyone who was sharing the same bug as me.

The problem was that regardless of the paginated URL displayed in the browser, a visitor to SEOgadget would still see the same list of posts. That’s quite a limiting bug – only being able to see my last 10 posts!

Anyway, the problem turned out to be a piece of code I left behind on index.php when I was working out how to exclude specific categories from the home page, to support my WordPress jobs board enhancement. Oops!

Just for interest, the code looked like this:

if (is_home()) {
query_posts("cat=-44");

It’s the highly useful query_posts tag that can be used to determine which posts you’d like to be included (or removed) from The Loop. Once removed, the pagination began to work again.

For anyone looking to exclude posts from a specific category, try Advanced Category Excluder. It even allows control over RSS feeds, which is exceptionally useful if you don’t want to clog your RSS subscribers inboxes with jobs!

I Fixed My Broken WordPress Pagination, 5.0 out of 5 based on 2 ratings

Comments

  1. Sports Blog

    This worked perfectly for me. I had been looking for a solution to this problem for days and had no luck. I used the exact same string of code as you and once I removed it, the pagination worked again. Thanks, you’re terrific!