• Hi,
    I have a couple of custom archive pages where I limited the number of post by using this code:
    <?php
    $posts = query_posts($query_string .
    ‘&showposts=10’);
    if (have_posts()) : while (have_posts()) : the_post(); ?>

    For page 1 to page 7 the pagination is fine.
    however when it comes to page 8 till the last page, they all goes to 404 error page.

    I checked other archive pages where there are not using the code above, they all functioning well. So I conclude that is the code above that causing this problem.

    Any idea to fix this problem?

Viewing 15 replies - 1 through 15 (of 27 total)
  • I am guessing that the showposts change is made after the pagination has been calculated. Try this:

    <?php
    global $wp_query;
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts(
       array_merge(
          $wp_query->query,
          array('posts_per_page' => 10,
                'paged' => $paged,
                )
       )
    );
    Thread Starter TC.K

    (@wp_dummy)

    nope, it doesn’t work as well.

    Maybe it has to do with the function “query_post” itself?

    I don’t think it is query_posts.

    Did you use the code exactly as I posted it? How did it fail? How many posts do you have?

    A link to your site might help.

    Thread Starter TC.K

    (@wp_dummy)

    Yes, i did use the code u gave me. But it still not working.

    Sure you can goto see my site :
    The pagination works until page 17
    https://www.myhphone.com/news/page/17/

    and start from page 18, its not working anymore.
    https://www.myhphone.com/news/page/18/

    Thread Starter TC.K

    (@wp_dummy)

    How many posts do you have? In other words, how many pages should there be?

    Thread Starter TC.K

    (@wp_dummy)

    It should be 34 pages.

    What happens if you set Admin->Settings->Reading->’Blog pages show at most’ to 10?

    How many posts do you have?

    Thread Starter TC.K

    (@wp_dummy)

    I got set the ‘Blog pages show at most’ to 20, which is for my other category page that does not using the query_post code. They all works well.

    I have thousands of post in my site.

    I am trying to determine if the calculation of the number of pages is incorrect. You may have thousands of posts, but how many should be found in the page that is failing?

    Please set ‘Blog pages show at most’ to 10 and see if it makes a difference in the pagination on the page that is failing.

    Thread Starter TC.K

    (@wp_dummy)

    It works when its set to 10 posts.

    So, when the pagination is failing, the calculation of the number of pages is done using 10 (34), but the highest page number you can see is calculated using 20 (17).

    Please set ‘Blog pages show at most’ back to 20.

    I wonder if there is something else in your code that is causing the problem. Is there a ‘reset’ after the query_posts?

    Please post the code for the page in a pastebin and post a link to it here.

    Thread Starter TC.K

    (@wp_dummy)

    Okay, I set it back to 20.

    Nope I did not use reset in my query_post.

    the code of the page is at here : https://pastebin.com/sa48h7iA

    Thread Starter TC.K

    (@wp_dummy)

    Okay, I set it back to 20.

    Nope I did not use reset in my query_post.

    the code of the page is at here : https://pastebin.com/sa48h7iA

    Please put in the code I suggested and put it in the pastebin.

Viewing 15 replies - 1 through 15 (of 27 total)
  • The topic ‘Archive Pagination goes wrong after few page.’ is closed to new replies.