Forums

Archive Pagination goes wrong after few page. (26 posts)

  1. WP_Dummy
    Member
    Posted 1 year ago #

    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?

  2. vtxyzzy
    Member
    Posted 1 year ago #

    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,
                )
       )
    );
  3. WP_Dummy
    Member
    Posted 1 year ago #

    nope, it doesn't work as well.

    Maybe it has to do with the function "query_post" itself?

  4. vtxyzzy
    Member
    Posted 1 year ago #

    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.

  5. WP_Dummy
    Member
    Posted 1 year ago #

    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
    http://www.myhphone.com/news/page/17/

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

  6. WP_Dummy
    Member
    Posted 1 year ago #


  7. vtxyzzy
    Member
    Posted 1 year ago #

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

  8. WP_Dummy
    Member
    Posted 1 year ago #

    It should be 34 pages.

  9. vtxyzzy
    Member
    Posted 1 year ago #

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

    How many posts do you have?

  10. WP_Dummy
    Member
    Posted 1 year ago #

    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.

  11. vtxyzzy
    Member
    Posted 1 year ago #

    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.

  12. WP_Dummy
    Member
    Posted 1 year ago #

    It works when its set to 10 posts.

  13. vtxyzzy
    Member
    Posted 1 year ago #

    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.

  14. WP_Dummy
    Member
    Posted 1 year ago #

    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 : http://pastebin.com/sa48h7iA

  15. WP_Dummy
    Member
    Posted 1 year ago #

    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 : http://pastebin.com/sa48h7iA

  16. vtxyzzy
    Member
    Posted 1 year ago #

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

  17. WP_Dummy
    Member
    Posted 1 year ago #

    http://pastebin.com/x0TMKA0J

    I don't know whether I put the code correctly. If you cannot view it, maybe I should paste it here?

  18. vtxyzzy
    Member
    Posted 1 year ago #

    By the Forum rules, you can't post long bits of code here. You must use the pastebin.

    Both of the pastebins show your old code. Please put in the code I suggested, run it to make sure there are no errors, and put it in a pastebin.

  19. thelumberjack
    Member
    Posted 1 year ago #

    Try replacing your query with the following code:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args= array(
    'showposts' => 10,
    'paged' => $paged
    );
    query_posts($args);
    
    if (have_posts()) : while (have_posts()) : the_post();
    ?>
  20. WP_Dummy
    Member
    Posted 1 year ago #

  21. vtxyzzy
    Member
    Posted 1 year ago #

    @thelumberjack: I think he needs to keep the original query args because he is restricting to a category query.

  22. WP_Dummy
    Member
    Posted 1 year ago #

    @thelumberjack : I had tried this trick before, but still unable to solve the problem. Anyway thanks for the advise.

  23. thelumberjack
    Member
    Posted 1 year ago #

    Damn. I had a very similar problem and the code I pasted worked for me. Best of luck with finding a solution!

  24. vtxyzzy
    Member
    Posted 1 year ago #

    Sorry, but after all the effort you had to show me what I asked for, I don't see the problem.

    I don't have an answer for you.

  25. WP_Dummy
    Member
    Posted 1 year ago #

    @vtxyzzy : It's ok, but I really appreciate what you have done for me. Maybe I should set 'Blog pages show at most' back to 10. Then it settle all the hassle.

  26. vtxyzzy
    Member
    Posted 1 year ago #

    You might try the Category Pagination Fix plugin.

  27. WP_Dummy
    Member
    Posted 1 year ago #

    I already use this plugin. Still not helping.

  28. vtxyzzy
    Member
    Posted 1 year ago #

    From other posts on this forum, I think this is a bug in WordPress that happens when the 'Blog shows at most' value is higher than the value used in a query.

    I have not seen a solution.

Topic Closed

This topic has been closed to new replies.

About this Topic