Archived topic
GeneratePress and GenerateBlocks conflict destroys pagination
9 replies · Started by Vlad on August 22, 2022
Hello GP team,
On my website I use GeneratePress Pro and GenerateBlocks Pro (latest versions). The main page is split in two parts: in the upper part I have a query GenerateBlocks block ("magazine featured posts" by David) that displays 4 posts via block-hook in the "generate_inside_site_container" hook. In the lower part I have the default latest posts list with infinite scroll and the "load more" button activated.
The problem is there seems to be a conflict between the GP and the GB plugins: when I click on "load more", new posts get added in the GB block container (upper part of the page, right beneath the 4 posts GB container) instead of being added at the bottom of the page. It's a div withe the class "gb-inside-container".
Also, the "load more" button now moves at the end of the new, malformed posts list instead of staying at the bottom of the page. However, if I remove the GB query block, the site works fine.
This is the only customization I made (no code whatsoever. I only used the GB and GP options). Any ideas on how I could solve this?
Thanks a lot,
Vlad
Hi Vlad,
Can you try adding this filter?:
add_filter( 'post_class', function( $classes ) {
$infinite_scroll_item_index = array_search( 'infinite-scroll-item', $classes );
if ( in_array( 'gb-query-loop-item', $classes ) && $infinite_scroll_item_index !== false ) {
unset( $classes[ $infinite_scroll_item_index ] );
}
return $classes;
} );
Adding PHP reference: https://docs.generatepress.com/article/adding-php/#code-snippets
Hello Fernando,
Nice, it works! What if I decide to use the same GenerateBlocks block on a category or a tag archives page, with the same layout and settings?
Will I need another fix or is this snippet enough to remove all potential conflicts between the GB blocks and the standard posts infinite queries?
EDIT: It only works on desktop. If I tap on "load more" on mobile, the button disappears and nothing happens.
Thank you,
Vlad
The filter removes the infinte-scroll-item class if it is query loop item so that issue doesn’t occur in any archive page.
Our team is planning a fix to this issue in the next update. The filter is a temporary fix.
I've just edited my last answer. The filter only works on desktop, on mobile the "load more" button disappears once I click on it and then nothing happens - no new posts are being loaded.
Can you try clearing cache or using a different mobile to test?
You were right, Fernando. It was a caching issue - for some reason I had to clear the cache 3 times for my phones to use the new page settings.
Our team is planning a fix to this issue in the next update. The filter is a temporary fix.
Once the update is out, will I have to manually remove the filter, or will the update overwrite it anyway?
You can remove it manually after the update for the fix. Leaving it shouldn’t cause any issues as well.
OK, thank you for your help, Fernando! Great support, as always. All the best!
You’re welcome Vlad!