17th Jun '22
/
24 comments

Masonry for Query Loop in Bricks

If you are looking to implement masonry with a 'view more' button i.e., click-type of infinite scroll follow this tutorial instead.

Updated on 15 Mar 2023

This Pro tutorial provides the steps to apply a responsive masonry layout for the posts output using Query Loop feature of Bricks.

Note that there is a built-in option for displaying posts in masonry layout in the Posts element (which we believe could have been implemented better. At the moment, there will be unwanted space for the items in the right-most column).

This tutorial is for those who want full control of the loop via Query Loop and masonry implemented without the above-mentioned issue.

Step 1

Edit your Page/Template with Bricks.

Add a Section.

Add a Container inside the Section's Container and change its name to say, "Masonry Grid". This is going to be the parent for each repeating item (post). Assign this a class of masonry-grid.

Add a Block inside. Toggle "Use query loop" to on. Configure the query as needed.

Update: The JavaScript code in Step 2 has been updated to enable support for Infinite scroll. You could enable it in the query loop setting.

Rename this to say, "Article".

HTML Tag: article

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 628 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Post-specific ACF Repeater Galleries as Sliders in Bricks

Post-specific ACF Repeater Galleries as Sliders in Bricks

How to output ACF Repeater field rows with the images of the Gallery-type sub field as a slider.
Pro
Masonry + Click-type Infinite Scroll in Bricks

Masonry + Click-type Infinite Scroll in Bricks

This Pro tutorial provides the steps to lay out posts in a masonry style with a View More button, which, when clicked, loads the next…
Categories:
Pro
Query Loop in Bricks

Query Loop in Bricks

This Pro tutorial walks you through the steps to use the Query Loop feature in Bricks to display a responsive grid of posts using CSS…
Categories:
Pro
Bricks Query Loop – How to Insert Elements After Every Nth Post

Bricks Query Loop – How to Insert Elements After Every Nth Post

Update: Follow this tutorial instead. This Pro tutorial provides the steps to output element(s) in a Bricks' query loop after every nth post. Use case:…
Categories:
Displaying SureCart Featured Products & Products Collections with a Query Loop

Displaying SureCart Featured Products & Products Collections with a Query Loop

We walk through how to use a query loop to display SureCart products, featured products & collections.
Categories:
How to create a dynamic infinite logo slider with ACF and Bricks

How to create a dynamic infinite logo slider with ACF and Bricks

This tutorial provides the builder settings, PHP & CSS codes that can be pasted in order to create an infinite logo slider in pure CSS…
Pro
Displaying Gallery of SureCart Product Images with Bricks’ Query Loop

Displaying Gallery of SureCart Product Images with Bricks’ Query Loop

Custom query loop for looping through SureCart product images.
Categories:
Tags:
Pro
How to Query WordPress Taxonomy Terms by Hierarchy Level in Bricks

How to Query WordPress Taxonomy Terms by Hierarchy Level in Bricks

How to limit the terms of a Bricks Terms query to only those at a specific level within the taxonomy hierarchy.
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…