Category pagination fix – WordPress plugin

Update (07 December 2011) : An update has been made to the plugin and is available for download from WordPress plugins directory. This will fix pagination on custom post types as well.


Plugin name : Category pagination fix
Release date : 2009-04-25

Description

Fixes the bug in WordPress 2.7 ( may be in lower version also) in category listing page pagination. When you are using permalink structure as %category%/%postname% , second page URL of category listing page will be category-name/page/2 which WordPress identify “page” as post name. And will return 404 error page. This plug-in will fix the issue. This also fix the next and previous buttons bug in while using custom permalink structure.

I’m using this plug-in for this blog itself 🙂

Installation

1 . Unzip into your /wp-content/plugins/ directory.

2 . Activate the plugin through the ‘Plugins’ menu in WordPress

Known issues

No issues reported yet. Please report issues in comments

Download

Category pagination fix 1.o

View Comments

  • WOW!!! this work really!!!! I spent upto 20+ hours on fixing the issue, but when I install this plugin now everything is working perfect!!!!!!!

    THANKS!!!!!!!!!

  • AMAZING!!!! I have been struggling with this problem for a month now, even the maker of the template I was using couldn't help me. I tried just about every solution I could find to no avail.

    Your code fixed it.
    THANK YOU, THANK YOU!

  • Hi, I have the same issue but whit tags. Works perfect with categories but not with tags.

    ¿Any suggestion please?

  • Fix for the custom types:

    Add this to functions.php

    add_rewrite_rule("[posttype]" . '$',
     "index.php?pagename=[posttype]",
     "top"); add_rewrite_rule("[posttype]" .
     '/page/([0-9])*/?', "index.php?pagename=[posttype]" . 
    '&paged=$matches[1]', "top"); 
    global $wp_rewrite; 
    $wp_rewrite->flush_rules();
    

    Change [posttype] to the name of your posttype.

  • Remiz,
    I tried your plugin with the latest version of WP (3.2.1.) but I can't seem to get it to work. It gives me additional pages but when I try and click beyond page 2 I end up with a 404 page, which is kind of weird since that second page is fully working... (like this - "x.com/news/page/2"). Could this have something to do with how the function calculates the number of pages, or is is something entirely else? Would really appreciate any help with this.

    • Im on 3.2.1 and it works fine. It seems not working fine if you are using Custom post types. Ill need some time to find a solution. At present Im busy with something else. Mostly some one might have already come up with a solution for this

  • Unfortunately, this did not work for me on WP 3.2.1. With (and without) the plugin installed, my pagination works on my general blog page; however the pagination breaks if you are viewing individual categories. Any ideas on how to fix this issue?

    Working pagination > http://www.sample.com/blog/
    Broken pagination > http://www.sample.com/category/news/
    
    Code:
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query('showposts=1'.'&paged='.$paged);
    
    while ($wp_query->have_posts()) : $wp_query->the_post();
      // do stuff
    endwhile;
    
    previous_posts_link('« Previous Entries');
    next_posts_link('Next Entries »');
    
    $wp_query = null; $wp_query = $temp;
    

    Cheers,
    Brad