HTML Remix - Dont copy code, remix it!

April 25, 2009

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


Incoming search terms:

wordpress category pagination, pagination category wordpress


75 Responses to “Category pagination fix – WordPress plugin”

  1. 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.

  2. Staffan Estberg says:

    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.

  3. brad says:

    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

  4. nykel says:

    the problem persist, wuat a have to do?
    helpe me please.

  5. nykel says:

    i have the same problem, i ever oploat end activated but the problem no fixed.

    help please

  6. HJK says:

    You are great!!!!!

  7. Kacie Jongsma says:

    Awesome info once again! Thanks!

  8. beninsky says:

    Same Problem here with WordPress 3.2 WP, “No Category Base” and “WP-PageNavi” plugins installed :(

    I’m so disapointed, I was so close to the Perfect URL Structure for SEO :P

    Can someone fix this? :( It would be greatly appreciated :)

    • beninsky says:

      nvm my problem is fixed with putting /%slug%/%postname% instead of /%category%/%postname%

      or maybe I did something else but now it Works :)

      • Awesome!!! Changing permalink structure like you wrote helped! Thank you.

      • Toby G says:

        Having the same problem with 3.2.1.
        I tried changing to using /%slug%/%postname% which stopped the 404 & worked OK for categories, but the actual post URLs now include the actual text “%slug%” rather than the suitable replacement.

        I think have solved this one though… if you change all references of “$query_string['name']” for “$query_string['pagename']” it seems to do the trick.

  9. [...] is a category, you may be a victim of the ‘Category Pagination bug’. This plugin claims to be a fix. Related Articles:uptonpickman on "query_posts() and pagination on [...]

  10. fajy says:

    Hello,

    I am using wp 3.1.1 and I set Permalink to /%postname%/.

    Since some days to click to categories get to the 404 error.
    If I click to the post itself, it works.

    I tried many suggestions around the net (including rewriting of the .htaccess) but it doesn’t work.

    I tried your plugin too and it doesn’t work…

    Do you have perhaps some other idea ?

    Thanks to help me.

    Best regards
    Fajy

  11. Alex says:

    I have the Bold theme by elegant themes and this fix didn’t work for me. Secondary pages still don’t appear. Please help.

  12. Antares says:

    Hi, thanks Remiz.

    It’s possible that work fine in subcategories?
    .
    Cheers

  13. Paulie B says:

    I’ve recently installed the plugin on my WP 3.0.4 site. I am still getting the 404 error on page 2 or above of my custom post type archive page. I don’t have any pages named the same as my post type so I’m not sure what else could be causing the issue.

    Could you suggest any other solutions?

    Thanks.
    Paul

    • Remiz says:

      This plugin seems to have issue with Custom post types. I will try on it over free time. Let me know if you got it fixed. I will upload to wordpress plugin directory so that everyone can use it

  14. PHP Freelancer India says:

    It is not working for me.

    I need to make a pagination for category page.

    Please have a look into plugin and let me know if you can help me.

  15. Steve says:

    BOSS!! Thank YOU!

  16. Mariano says:

    It’s doesn’t work for me, I’m using wp3.01… nothing happend

  17. Alex says:

    This works great. Saved me a ton of time. Thanks so much.

  18. How about pagination error in the posts. My category pagination is working fine, but I’m having problem with the post pagination. Our blog is located here – http://www.lamandier-maroc.com/blog. The next page link /blog/index.php/page/2 is returning 404. Have you had some issues regarding this before? It’s on WordPress 2.7 by the way.

    Thanks!

  19. AJ Quick says:

    Unable to use search function on pages.

    Example:

    /category/page/?s=search+terms&searchbtn=Go

    If there are no results it will display the no results page.

    If there are results it will just display the page you are on as if nothing happened. Might be related to this plug-in?

  20. Sam Neirynck says:

    Hello, I’m still having troubles. I”m using 2.9.2, but the issue is still there.
    I downloaded the plugin, put it in the /plugins directory, activated it, but I still get the 404 message.

    Any help please?

Leave a Reply


1 + two =