The Load More feature is something we have already in Bricks ideas board (https://bricksbuilder.io/ideas/#3111). Make sure you upvote it and comment if you would like to add some more details.
It is rather complex to explain in a post how to achieve the Load More feature with custom code, but you would need to have a load more button which when clicked would trigger an ajax call to fetch the next page of posts, and then append that HTML to the end of the list. The ajax call needs to carry the page number and you would need to modify the query (Filter: bricks/posts/query_vars – Bricks Academy) before rendering the template.
Regarding this part of the code:
I strongly suggest you replace that code by the following because we might change the internal class methods one day, and that will break your code:
function sal_render_bricks_template($template_id){
return do_shortcode('[bricks_template id="'.$template_id.'"]');
}
I was wondering if you are aware that you can do it with the new interactions on Bricks Builder. You simply add a button, select internactions → Trigger = Click, Action = Load more (Query loop), Query= the related query.
Thanks for this tip, was able to add ‘Load More’ button in the query loop.
How do i change the cursor to indicate that the button is clickable when hover. In the current state since the button doesn’t contain any link the cursor remains normal when hover.
”;
wp_reset_postdata();
}
}
my template have element heading “dynamic data” {post_title} by After passing the above query, my template only retrieves the title of the page but does not retrieve the title of the query
@wplit Can you please help me how to load the posts with some smooth transitions with the above interaction method
button, select internactions → Trigger = Click, Action = Load more (Query loop), Query= the related query.
Sorry to bump but I just debugged my issue regarding the load more interaction on a button.
Like me, your load more button probably was a link with ‘#’ added to the button.
Once I removed the ‘#’ href and turned it into a button, everything works as it should.
Only issue I am facing is now an accessibility one, in that if a user keyboard navigates to press the load more button after the first set of X items, the focus stays on the button, rather than focusing to the X+1 item in the query which would be desirable. I don’t think Bricks natively handles this?