[Resolved] GeneratePress and GenerateBlocks conflict destroys pagination

Home Forums Support [Resolved] GeneratePress and GenerateBlocks conflict destroys pagination

Home Forums Support GeneratePress and GenerateBlocks conflict destroys pagination

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #2320669
    Vlad

    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

    #2320780
    Fernando
    Customer Support

    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

    #2320796
    Vlad

    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

    #2320798
    Fernando
    Customer Support

    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.

    #2320807
    Vlad

    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.

    #2320820
    Fernando
    Customer Support

    Can you try clearing cache or using a different mobile to test?

    #2320838
    Vlad

    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?

    #2320843
    Fernando
    Customer Support

    You can remove it manually after the update for the fix. Leaving it shouldn’t cause any issues as well.

    #2320844
    Vlad

    OK, thank you for your help, Fernando! Great support, as always. All the best!

    #2320846
    Fernando
    Customer Support

    You’re welcome Vlad!

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