- This topic has 10 replies, 5 voices, and was last updated 3 years, 4 months ago by
Leo.
-
AuthorPosts
-
January 21, 2022 at 6:25 am #2088520
J.
Hi there,
I’m using the ‘Volume’ template. Is it possible to get 9 blog posts on the homepage and 10 on the following pages? It seems a bit odd when using the standard setup with the big featured post on the homepage.
January 21, 2022 at 6:47 am #2088566David
StaffCustomer SupportHi there,
you would need to add this PHP Snippet to your site:
add_action( 'pre_get_posts', 'sk_query_offset', 1 ); function sk_query_offset( &$query ) { if ( is_admin() ) { return; } // Before anything else, make sure this is the right query... if ( ! ( is_main_query() ) ) { return; } // Don't do anything to Elements. if ( 'gp_elements' === $query->get( 'post_type' ) ) { return; } // First, define your desired offset... $offset = -1; // Next, determine how many posts per page you want (we'll use WordPress's settings) $ppp = get_option( 'posts_per_page' ); // Next, detect and handle pagination... 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. Set a different number for posts per page $query->set( 'posts_per_page', $offset + $ppp ); } } add_filter( 'found_posts', 'sk_adjust_offset_pagination', 1, 2 ); function sk_adjust_offset_pagination( $found_posts, $query ) { if ( is_admin() ) { return; } // Define our offset again... $offset = -1; // Ensure we're modifying the right query object... if ( is_main_query() ) { // Reduce WordPress's found_posts count by the offset... return $found_posts - $offset; } return $found_posts; }This article explains how to add PHP:
January 21, 2022 at 7:00 am #2088573J.
I’ve pasted this in the functions.php from my (clean) child theme, but I see no results… Am I doing something wrong?
January 21, 2022 at 7:14 am #2088646David
StaffCustomer SupportCan you share a link to the site ?
January 22, 2022 at 7:06 am #2089615J.
Shared in the private info.
January 22, 2022 at 11:42 am #2090000Ying
StaffCustomer SupportHi Joe,
The code should work, I just tested on my site.
Can you disable all other plugins except GP premium and GB to test?
November 19, 2022 at 6:42 am #2422854jmarc
Hi
I use this code for my site but pagination is not working fine for the last page…
Can you please take a look ?
Thank youJMarc
PS : how do I send you the URL in private so you can check the site ?
November 19, 2022 at 1:04 pm #2423329jmarc
Someone can help please ? Thank you 😉
November 19, 2022 at 1:07 pm #2423331Leo
StaffCustomer SupportPlease open a new topic so you can use the private URL field:
https://docs.generatepress.com/article/using-the-premium-support-forum/#open-support-topic
https://docs.generatepress.com/article/using-the-premium-support-forum/#private-informationPlease also be mindful that it’s Saturday here so our responses will be slower:
https://generatepress.com/what-support-includes/Thanks for your understanding 🙂
November 19, 2022 at 1:22 pm #2423342jmarc
I’ll do that and I thank you Leo ….
November 20, 2022 at 12:43 pm #2424464Leo
StaffCustomer SupportThanks 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.