Support » Fixing WordPress » pagination problem with last set

  • hi everyone… getting crazy with this issue:

    I have correctly implemented page navigation for my site and it works fine. Really good job! 😉
    The problem is that the last set of posts is not displaying correctly: it just mess up the style and “No articles” is written even if there are still 2 posts to display.
    It seems the pagination is not working if there are less than 10 posts to display (the query is set to display 10 posts max).

    The code of the page is:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    There are 2 loops inside the page. the primaty one which is paginated and the second one in the sidebar.

    Anyone has an idea why the last set of posts to display does not work? Please help! Already searched everywhere but without success!

Viewing 15 replies - 1 through 15 (of 25 total)
  • You are passing the variable $additional_loop->max_num_pages to the paginate function. I do not see where that variable is set. I believe that this should be $wp_query->max_num_pages.

    Thank you for the answer! I had a look in the function page where the pagination function is stored. There is the max_num_pages inserted this way:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Any idea? Please help… getting crazy!
    Thanks

    You are not calling the function with the proper max_num_pages. Change this:

    <?php if (function_exists("pagination")) {
        pagination($additional_loop->max_num_pages);
    } ?>

    to this:

    <?php if (function_exists("pagination")) {
        pagination($wp_query->max_num_pages);
    } ?>

    thank you!
    OK now it works but not completely. It misses the last 6 posts of the set. In total there are 26 posts under this category but the navigation finishes at 20 and not showing the other 6.

    Well… if you wanna have a look:

    http://www.snowboarditaliamag.it

    Try to go from the menu in MAGAZINE > RACCONTI

    thank you again!

    Please delete the userid and password from above immediately!!

    done! sorry…. there was user & oass for the accessing php directory….
    anyway…
    http://www.snowboarditaliamag.it/mag/racconti/page/3 this is the url which would be supposed to display the latest 6 posts of the 26… it is no working as you can see… with your changing now the link at the third (last) page isn’t showed but latest 6 posts are missing…

    I really can’t tell anything from just looking at the site.

    Can you add a line under the query to show the number of posts found, like this:

    <?php global $query_string; query_posts($query_string . '&showposts=10' ); ?>
    <?php echo "FOUND POSTS: $wp_query->found_posts<br />"; ?>

    and see what it prints?

    It writes 26 like the total number of posts in this category.
    It misses the last page where there are less than 10 posts. I think this is the problem which creates the page with “No articles”
    It happens for every categories whit this query and ‘pagination’ function…

    I wonder if the pagination call needs to be before the ‘else’ part of if (have_posts()), like this:

    <!-- END LOOP -->
          <!-- PAGINATION FUNCTION -->
    
    <?php if (function_exists("pagination")) {
        pagination($wp_query->max_num_pages);
    } ?>
    
           <?php else: ?>
    <h2><?php _e('Nessun articolo presente'); ?></h2>
    <p class="center"><?php _e('Nessun articolo presente'); ?></p><?php endif; ?>

    Well… just tried without success… I have tried both:

    <?php if (function_exists("pagination")) {
        pagination($wp_query->max_num_pages);
    } ?>

    in this case the last link to the last page containing the last 6 posts (out of 26) is not displayed…
    With this code:

    <?php if (function_exists("pagination")) {
        pagination($additional_loop->max_num_pages);
    } ?>

    the last link to the last page containing the last 6 posts (out of 26) is displayed but if clicked it does return “No article available” and the page does not show the last 6 posts….

    I’m getting creazy… such a strange behaviour… no idea…. 🙁

    OK – please try a little more debugging. Print the max_num_pages like this:

    <?php global $query_string; query_posts($query_string . '&showposts=10' ); ?>
    <?php echo "MAX PAGES: $wp_query->max_num_pages<br />"; ?>

    ok… the result is MAX PAGES: 2

    It is not correct: there are 6 posts missing which would make the third page with following url: ……/page/3

    I’ve taken the function script that is currently used from this page:

    http://design.sparklette.net/teaches/how-to-add-wordpress-pagination-without-a-plugin/

    The problem is that the query shows only 2 pages, so no matter which pagination function you use, it will only give 2 pages.

    Now, the question is “Why is the query only showing 2 pages?”

    Let’s see what the $query_string is like:

    <?php global $query_string; query_posts($query_string . '&showposts=10' ); ?>
    <?php echo "QUERY STRING: $query_string<br />"; ?>

    This is for the category with 26 posts:

    QUERY STRING: category_name=mag%2Feventi-contest

    This is another categoru with more or less 330 posts:

    QUERY STRING: category_name=mag%2Feventi-contest

    I found other relevant problem like if I use pagination($additional_loop->max_num_pages); then I get a certain number of links which are less than the supposed number of links that the number navigation should display… if i use: pagination($wp_query->max_num_pages); I get more number links but lasts of them does not work even if the number ok links which should be displayed is correct (like 33 for eventi-contest category which contains more or less 330 posts). But if I click link number 25 or 30 I get always the same error “No article sorry”……

Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘pagination problem with last set’ is closed to new replies.