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.
Thread Starter
tctc
(@tctc)
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);
} ?>
Thread Starter
tctc
(@tctc)
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!!
Thread Starter
tctc
(@tctc)
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?
Thread Starter
tctc
(@tctc)
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; ?>
Thread Starter
tctc
(@tctc)
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 />"; ?>
Thread Starter
tctc
(@tctc)
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
Thread Starter
tctc
(@tctc)
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 />"; ?>
Thread Starter
tctc
(@tctc)
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”……