Black Friday Sale! Get $20 off GP Premium, $40 off our new Lifetime license, and 45% off license renewals/extensions! Learn more

[Resolved] Removing extra page numbers in pagination.

Home Forums Support Removing extra page numbers in pagination.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #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

    GP Premium 1.4.3
    #396961
    Tom
    Lead Developer
    Lead Developer

    Huh, 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?

    #397150
    Morten

    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.

    #397179
    Morten

    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 );
    }
    }

    #397386
    Tom
    Lead Developer
    Lead Developer

    You 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 );
        }
    }
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.