Home › Forums › Pro Support › Pagination Repeating Posts Problem
Tagged: Pagination Repeating Same Posts
- This topic has 9 replies, 2 voices, and was last updated 2 years, 6 months ago by
elvin.
-
AuthorPosts
-
March 20, 2021 at 7:09 pm #28287
Michelle
ParticipantI 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?
March 21, 2021 at 8:05 pm #28306elvin
ModeratorHi 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.
March 22, 2021 at 9:33 am #28341Michelle
ParticipantNo. 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?
March 22, 2021 at 9:37 am #28343Michelle
ParticipantI sent the info to GeneratePress.
March 22, 2021 at 5:41 pm #28370elvin
ModeratorThanks,
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.
March 22, 2021 at 6:08 pm #28379Michelle
ParticipantHello. I disabled all plugins except for WPSP and the issue still occurred.
Bummer!
March 22, 2021 at 6:36 pm #28383elvin
ModeratorCan 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?
March 22, 2021 at 8:50 pm #28385Michelle
ParticipantYes, 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?
March 22, 2021 at 9:23 pm #28391Michelle
ParticipantIs there a way to achieve this with CSS?
March 23, 2021 at 10:39 pm #28428elvin
ModeratorYes, 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_PaginationBut 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'
-
AuthorPosts
- You must be logged in to reply to this topic.