Archived topic
An issue with the load more button
5 replies · Started by Leo on January 3, 2023
Hi!
I sent a ticket to GenerateBlocks a few days ago and never got a response, so I'm asking for help here.
I've remade my blog page because I used the old WP Show Posts plugin and wanted to update to the new Query Loop block.
Now, if you click the button to load more posts (at the bottom of the blog page), you get duplicated posts (already displayed), and new entries are loaded not right after the button but in the middle of the page.
(By the way, I found this topic dated a few months ago on the GenerateBlocks forum, pointing to a similar problem.)
I'd be very grateful if you could help me to solve the problem. Thanks.
Hi there,
sorry for late response, ill take a look into what happened on the GB Support forum.
How has the additional post lists been added to the blog page ?
Hi David,
I created an element (hook type) and hooked it to "before_main_content." This element is located on the default blog page and has three query loop blocks (displaying three different kinds of posts).
Since this is the WP default blog page, after the query loop blocks, it automatically displays an autogenerated list of posts and then the load more button that originates the problem.
I don't need this autogenerated list, but I don't know how to get rid of it (and the load more button). If you can tell me how to prevent displaying the WP autogenerated list of posts and its default button, it would also be OK.
Thanks! :)
Can you try adding this PHP Snippet to your site:
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;
} );
It's perfect now. Thank you very much, David! :)
You're welcome.