[Support request] Pagination Repeating Posts Problem

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Pagination Repeating Posts Problem

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #28287
    Michelle
    Participant

    I am using WP Show Posts Pro. I have it set to show 6 posts per page with pagination on the bottom.

    BUT – All of my pages show the first 6 posts over and over instead of moving to the next 6. I have more posts than 6 to show.

    How do I fix this?

    #28306
    elvin
    Moderator

    Hi there,

    Do you have multiple WPSP list on the same page? Any chance you could link us to the page in question to check what happens? Let us know.

    #28341
    Michelle
    Participant

    No. I do not have multiple lists on the same page. I have the site under maintenance mode. Where do you want me to upload my login credentials? Should I go to Generate Press so I have a place to upload them privately?

    #28343
    Michelle
    Participant

    I sent the info to GeneratePress.

    #28370
    elvin
    Moderator

    Thanks,

    Can you try disabling ALL plugins except WPSP to check if the issue still occurs? This is to check for any plugin conflicts.

    Let us know.

    #28379
    Michelle
    Participant

    Hello. I disabled all plugins except for WPSP and the issue still occurred.

    Bummer!

    #28383
    elvin
    Moderator

    Can you check if your WPSP list has any offset? Offset is known to break pagination.

    If it has one, can you try removing the assigned value?

    #28385
    Michelle
    Participant

    Yes, I have an offset of 1. This is what I bought WP Show Posts Pro for. I want to have the most recent post on the homepage, and the rest of the posts, minus the most recent, on the blog page (Writing).

    Why have offsets if you can’t use them?

    #28391
    Michelle
    Participant

    Is there a way to achieve this with CSS?

    #28428
    elvin
    Moderator

    Yes, I have an offset of 1. This is what I bought WP Show Posts Pro for. I want to have the most recent post on the homepage, and the rest of the posts, minus the most recent, on the blog page (Writing).

    Why have offsets if you can’t use them?

    The offset can be used for multiple post lists with no paginations on any of them.

    This is actually a WordPress core issue. See their statement here:
    https://codex.wordpress.org/Making_Custom_Queries_using_Offset_and_Pagination

    But to solve your specific issue, here’s a workaround:

    add_action( 'pre_get_posts', 'writing_page_WPSP_offset' );
    function writing_page_WPSP_offset( $query ) {
    	
    	//Before anything else, make sure this is the right query...
        if ( ! $query->is_home() ) {
            return;
        }
    
        //First, define your desired offset...
        $offset = 1;
        
        //Next, determine how many posts per page you want (we'll use WordPress's settings)
        $ppp = 5;
    
        //Next, detect and handle pagination...
    	if( is_page( 'Fundraiser' ) ){
    		if ( $query->is_paged ) {
    
    			//Manually determine page query offset (offset + current page (minus one) x posts per page)
    			$page_offset = $offset + ( ($query->query_vars['paged']-1) * $ppp );
    
    			//Apply adjust page offset
    			$query->set('offset', $page_offset );
    
    		}
    		else {
    
    			//This is the first page. Just use the offset...
    			$query->set('offset',$offset);
    
    		}
    	}
    }

    On this code, modify a few things:

    Change $ppp value from 5 to the number of post you want to display on the page.

    Also, on this line if( is_page( 'Fundraiser' ) ), change 'Fundraiser' to the name of the page you placed your WPSP list. Example: 'Writing'

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.