- This topic has 4 replies, 2 voices, and was last updated 8 years, 6 months ago by
Tom.
-
AuthorPosts
-
October 3, 2017 at 4:03 am #396473
Morten
1 have a problem with “extra” pages after going from one post per page to several post per page in blog. This meant that number of pages with content went down from 64 to 32. But in my pagination the last number of pages is still 64.
I simply do not know what to do…without accidentaly breaking the whole site to pieces 🙂
Any tips?
Site is http://www.williksenbloggen.no
October 3, 2017 at 5:59 pm #396961Tom
Lead DeveloperLead DeveloperHuh, never seen that before. GP uses the core WP the_post_pagination() function, so something must be messing with it.
Can you try deactivating your plugins one by one to see if one of them is causing the issue?
October 4, 2017 at 2:14 am #397150Morten
Thank you for fast reply. I have tried to deactive plugins, and did so again now. Still the same problem.
But I noticed something that I missed before. When I click on the navigation for example on page two, then the number of total pages goes to the true number – 34. This keeps on. But when I go to the front page, then the total number shows up as 64.Very strange. I think I choose a cheap solution and remove the total number box..
Thank you again.
October 4, 2017 at 3:05 am #397179Morten
This is the culprit:
function limit_posts_per_page() {
if ( is_home() && is_paged() )
return 6;
else
return 3;
}
add_filter (‘pre_option_posts_per_page’, ‘limit_posts_per_page’);The function multiplies the actual number of pages with two. It doubles the total number of pages. I’ll work on this to try to understand (and solve it). It is obviously not at Generatepress fault.
A while ago you gave med a function that worked, but it affected the adminpages with list of posts, too. First page of list contained three posts.
add_action( ‘pre_get_posts’, ‘tu_change_posts_per_page’, 1 );
function tu_change_posts_per_page( &$query ) {
if ( ! is_main_query() ) {
return;
}if ( ! $query->is_paged ) {
$query->set( ‘posts_per_page’, 10 );
}
}October 4, 2017 at 9:38 am #397386Tom
Lead DeveloperLead DeveloperYou could do this so it only applies on the front end:
add_action( 'pre_get_posts', 'tu_change_posts_per_page', 1 ); function tu_change_posts_per_page( &$query ) { if ( ! is_main_query() || is_admin() ) { return; } if ( ! $query->is_paged ) { $query->set( 'posts_per_page', 10 ); } } -
AuthorPosts
- You must be logged in to reply to this topic.