Support » Themes and Templates » Category Pagination broke with WordPress 3.4

Category Pagination broke with WordPress 3.4

Viewing 8 replies - 1 through 8 (of 8 total)
  • I just had this same problem begin happening today. At first I thought it was caused by a plugin, but then it happened after I removed that. I can’t tell what’s triggering it.

    Any ideas?

    I got the problem fixed by using the code below for URL rewrite and putting it in functions.php. Thanks to another WordPress user who contacted me directly

    function yoursite_init() {
      global $wp_rewrite;
    		//add rewrite rule.

    perfect, exactly what I needed. Bless you.

    I have the same problem here and this code didn’t worked for me.

    powerhomebiz, do you mind to share the code you’re using for your website pagination?

    I’ve got this one:

    //The Query
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $category_id = get_cat_id( single_cat_title("",false) );
    // Nova query para pegar todos os Projetos.
    $new_query = new WP_Query();
    $new_query->query('showposts=2&cat='.$category_id.'&paged='.$paged );
    $contador = 0;
    //The Loop
    if ($new_query->have_posts()) : while ($new_query->have_posts()) : $new_query->the_post();	
    if($new_query->max_num_pages>1){ ?>
    	<div id="paginationWrapper">
    	if ($paged > 1) { ?>
        	<a class="pagePrev" href="<? echo site_url('/') ?>videos/page/<?php echo ($paged -1); //prev link ?>"><<</a>
    <?php }
    	echo '<div class="pagination"><span class="pgnTitle">'. __('PÁGINA').'</span> <span class="pgnPage">0'. $paged .'</span></div>';
        if($paged < $new_query->max_num_pages){ ?>
            <a class="pageNext" href="<? echo site_url('/') ?>videos/page/<?php echo ($paged + 1); //next link ?>">>></a>
        <?php } ?>
    <?php } 
    endif; ?>

    The fix posted by powerhomebiz also worked for me.

    Running WP 3.4.1

    My default category was paging just fine, but my additional categories would not load anything past page 1.

    I had tried reinstalling 3.4, and rolling back to 3.3 with no luck. Applying the fix mentioned by powerhomebiz to the functions.php file in my theme folder seems to have resolved the issue.

    Moderator keesiemeijer


    The solution from powerhomebiz is flushing the rewrite rules on the ‘init’ hook. This is not recommended because it is an expensive operation.

    Try removing this line after you have pagination working and see if it still works:


    Another way to get pagination working on category pages is by not using a query_post or a new WP_Query() in the category template file. But by putting this in your theme’s functions.php:

    function my_post_queries( $query ) {
      // not an admin page and is the main query
      if (!is_admin() && $query->is_main_query()){
          // set the posts_per_page here
          $query->set('posts_per_page', 5);
    add_action( 'pre_get_posts', 'my_post_queries' );

    This example sets the posts per page to 5 on all category pages. If you only want this on a specific category change the is_category() conditional tag in the code


    Customizing the WordPress Query

    Many many thanks powerhomebiz,

    The fix works!! I can put “Category pagination fix” plugin to the trash. It didn’t work on last version 3.4.1.


    Best regards,

    Eventually, that’s the 3.4.1 causes the bug I had.

    The 3.4.2 version has fixed itself the rewrite rule bug.


Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Category Pagination broke with WordPress 3.4’ is closed to new replies.