13th Aug '24
/
6 comments

Load more for Query loops in Bricks

Did you know that Bricks has AJAX loading on-click for query loop posts out of the box?

This article shows how AJAX Load more functionality can be configured in Bricks.

Step 1

Edit your Page/template with Bricks.

Copy and paste the fully built Section of the above demo using this JSON.

Note: A few ACSS utility classes and variables are used.

A click Interaction has been set on the Button like this:

Select your query loop-enabled element’s label or ID in the Query control.

This is how the loading animation is made to appear inside the AJAX Loader div (below the button):

Step 2 (only if using ACSS)

Add this global CSS:

a[class*="btn--"].brx-load-more-hidden {
    display: none;
}

If you have Advanced Themer, you could do it right from within the builder.

That’s it. Save and check on the front end.

Reference

https://community.automaticcss.com/c/bricks/acss-overriding-brx-load-more-hidden-s-css

Get access to all 621 Bricks code tutorials with BricksLabs Pro

6 comments

  • Benjamin Ogg

    Dear Sridhar, This function is truly awesome. I have a UX improvement suggestion. Use Case:

    1. The user clicks the «Load more» button 3 times
    2. They click on a post and get to the page (in same window/tab)
    3. They click the browser back button

    Desired scenario: Currently, they have to start over and «retrieve» all posts again. Ideally, they could continue where they left off. Is this possible? Cheers, Benjamin

    • Benjamin Ogg

      Dear Sridhar, I just saw, that here in BricksLabs you have implemented this. When I scroll down on the archive page more posts are loaded. Navigating to a post in same window and then return to the archive by browser back button brings me back where I left. Awesome! That's exactly what I would love to have for this solution here too. Is that possible? Cheers, Benjamin

      • Tom Homer

        Hi Sridhar,

        I am wondering the same thing. To make Load More accessible it needs the following:

        Update Live Region: After loading new content, it's important to update a live region (using aria-live="polite") to inform users of the updated content, especially for screen reader users.

        Manual Focus: When new content loads, focus should be moved to the first interactive element in the new set of items, making it easier for users to navigate.

        Which Bricks native Load More doesn't do. WP GridBuilder does add the aria-live="polite" but doesn't do the manual focus.

  • eins walter

    Acss btn-- thing is great!!

    Does load-more work only with Bricks builder loop? Or Jetengine query in Bricks Builder too?

    • A

      Yes.

      I do not know if AJAX Loader works though. I've just sent a support email to Bricks about it.

      But having a button to load more posts and adding an interaction like I wrote in this tutorial works just fine.

  • Benjamin Ogg

    Absolutely brilliant! Thank you so much for this!

Leave your comment

 

Related Tutorials..

Pro
Posts older than today in Bricks

Posts older than today in Bricks

How to display only posts that were published before today in a query loop.
Categories:
Pro
Dynamic Posts Lightbox in Bricks using GLightbox

Dynamic Posts Lightbox in Bricks using GLightbox

Steps to set create a dynamic lightbox with content from the post inside of the query loop.
Categories:
Pro
CMB2 Repeatable Group Bricks Query Loop

CMB2 Repeatable Group Bricks Query Loop

This Pro tutorial provides the steps to create a custom query loop type for outputting the subfield values of a Group field (repeatable) when using…
Pro
Mixed Post Types Grid in Bricks

Mixed Post Types Grid in Bricks

How to set up a mixed post types grid in Bricks, where you can display both standard posts and custom quote cards in alternating positions.
Categories:
How to Show Future Events in Bricks

How to Show Future Events in Bricks

One of the common requirements in WordPress is being able to filter the events (or could be posts of any post type) to only those…
Categories:
Using WP Grid Builder Facets with Bricks’ Query Loop

Using WP Grid Builder Facets with Bricks’ Query Loop

Update: This tutorial was written before WPGB had a Bricks add-on. Now, it is advisable to use that add-on instead. Get it from here. Updated…
Categories:
Auto Responsive Grids in Bricks

Auto Responsive Grids in Bricks

This tutorial provides the CSS that can be pasted for automatic responsive grids in Bricks Builder. Posts element Each post will get a right padding…