Support » How-To and Troubleshooting » Page not found half way through pagination

Page not found half way through pagination

  • narkiej


    I am creating my loops with the following code: <?php query_posts('cat=164, -13&posts_per_page=6' . '&paged=' . get_query_var('paged')); if ( have_posts() ) : while ( have_posts() ): the_post(); ?>

    This works great and I can cycle through pages using pagination too. However for some inexplicable reason the on page 5 of pagination it takes you to an error Page not found page. And on another archive page I have created it goes to page not found on page 6.

    If this is of relevance i have used the following code in functions to get rid of the category prefix in my permalinks: `add_filter(‘user_trailingslashit’, ‘remcat_function’);
    function remcat_function($link) {
    return str_replace(“/category/”, “/”, $link);
    add_action(‘init’, ‘remcat_flush_rules’);
    function remcat_flush_rules() {
    global $wp_rewrite;
    add_filter(‘generate_rewrite_rules’, ‘remcat_rewrite’);
    function remcat_rewrite($wp_rewrite) {
    $new_rules = array(‘(.+)/page/(.+)/?’ => ‘index.php?category_name=’.$wp_rewrite->preg_index(1).’&paged=’.$wp_rewrite->preg_index(2));
    $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
    } `

    Please help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • richarduk


    I always use something like this for my index.php page

    <?php   $index_loop = new WP_Query();  $index_loop->query('order=DESC'.'&paged='.$paged);  ?>

    followed by something like this

    <?php if ($index_loop->have_posts()) :  while ($index_loop->have_posts()) : $index_loop->the_post(); ?>

    I don’t know if you’re referring to index.php or not, but pagination there is an issue. It might that simply rewriting what you already have in the form above makes a difference.

    The only other thing I’d suggest is seeing what happens when you remove the -13 bit.



    Hello! Just tried your method and it works well. I have found out that what causes the problem is &posts_per_page=6

    WIth my previosu code the final 3 pages had errors.

    When i add &posts_per_page=6 to you code, pagination doesnt even display the page numbers that previously didnt work.

    EG with my previous code:

    I get: Pagination: 1,2,3,4,5,6,7,8,9 (7,8,9 are error pages when you click)

    With your code I get:1,2,3,4,5,6 (Which isnt all of my posts)




    Try posts per page at different numbers. WordPress hasn’t quite got the calculations sorted IMO – there’s a bug IMO with comment pagination along the same lines – I’m guessing it takes the total number of posts, divides by the number to show per page, then gets a bit left over. That bit left over seems to throw it. Making posts per page 12, or 20 might mean that all your posts show up.



    Thanks for your help, i’ve got it working by chaning posts per page to 6 actually. and if i need to call any querys of more posts per page it works fine.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Page not found half way through pagination’ is closed to new replies.