24th Jun '22
/
3 comments

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 Grid while reducing the load on the database using a Bricks filter hook.

For each post we are going to set up:

  • featured image in a custom image size linking to post's permalink
  • post title linking to permalink
  • post excerpt
  • Read more button linking to permalink

We shall also ensure that the Read more button is positioned at the end (vertically) of each post.

This example is mainly meant for secondary queries where a fixed number of posts (6 in this case) are to be shown.

Step 1

Edit your Page with Bricks.

Posts Grid Query Loop Section

You can skip this entire step and simply import the Posts Grid Query Loop Section file from our test site if you want. This is provided near the end of this step.

If you want to get familiar with Bricks and learn and ins-and-outs, we recommend doing it manually as detailed below.

Add a Section. In Bricks version 1.4.0.2 and earlier, this is done by clicking the + icon, then the Layout icon (on the Container element) and clicking on "Full width (Section)".

This adds a Section having a Container.

Select the Container and add a Heading element.

You may want to change the text to something like "Latest Posts".

Add a Container below the heading. This will be the parent container of all the posts. You might want to double click on the layer name in the structure panel and rename it to something like "Posts Grid".

Let us add a bit of custom CSS for an automatic (no need to set breakpoint-specific CSS using media queries) responsive grid.

STYLE → CSS → Custom CSS:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 611 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Nav Menus Custom Query Types in Bricks

Nav Menus Custom Query Types in Bricks

Updated on 21 Aug 2024 This Pro tutorial shows how custom query types for each navigation menu can be generated in Bricks. This enables us…
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:
Pro
Child Posts Section in Bricks

Child Posts Section in Bricks

This Pro tutorial provides the steps to limit the posts (can be of any post type) output by Bricks' query loop to children of the…
Categories:
Pro
Parent post Bricks query loop

Parent post Bricks query loop

Updated on 5 Feb 2024 In the BricksLabs Facebook group a user asks: Is there a way to output the data of a parent post…
Categories:
Pro
Posts from Random Categories in Bricks

Posts from Random Categories in Bricks

Updated on 31 Jul 2023 In BricksLabs Facebook group a user asked: How would you query 3 WordPress posts from 3 different categories with Brick…
Pro
Post Views Counter Query Loop in Bricks

Post Views Counter Query Loop in Bricks

How we can output the most viewed posts in your Bricks site in a query loop.
Categories:
Pro
Related Episodes Grouped by Episode Chapters on Single Podcasts in Bricks when using JetEngine

Related Episodes Grouped by Episode Chapters on Single Podcasts in Bricks when using JetEngine

A user asks: How to Display Related Episodes Grouped by Chapters on a Podcast Page in Bricks? Hi everyone, I have two post types created…