2nd Jul '25
/
5 comments

Mixed Post Types Grid in Bricks

A user asks:

Hey everyone — I’m building a grid in Bricks loop (3 columns) and I want to inject random quote cards in alternating positions across rows (3rd, 2nd, 1st, etc). (I’m thinking about a quote CPT)

I’ll be using the bricks query filters to handle this.

I know I could build the whole thing custom too, but I’m aiming to achieve the layout in the screenshot I’ll share using the maximum of Bricks builder.

Curious how others would approach it, please let me know your thoughts

Thank you

If items of both the post types are to show the same type of data, for example, post title, published date and excerpt we could set up data attribute or a dynamic class on the query loop and add CSS order property to manually arrange the quote posts in each row. This is especially true when the number of items in the grid is fixed - say 9.

For maximum flexibility though, when the number of posts could be 9 or any other number, it is better to have two different conditional blocks - each having the elements needed for that post type and write PHP to set post__in query param to the items in the desired order:

post, post, quotepost, quote, postquote, post, post

We shall set up custom fields for icon, background color and text color for the quote posts, pull their values and show/apply to the quote posts.

This Pro tutorial provides the steps to set up a mixed post types grid in Bricks, where you can display both standard posts and custom quote cards in alternating positions using custom PHP query, custom fields, and conditional blocks for maximum layout flexibility.

Step 1

Create quote CPT using your favorite plugin.

We are using ACF in this tutorial.

Create custom fields.

Add quote posts.

Publish more than 3 since you want these to be random.

Step 2

Whitelist the get_post_type function. We will be using this to conditionally render elements depending on the post type.

Ex.:

<?php add_filter( 'bricks/code/echo_function_names', function() { return [ 'get_post_type' ]; } );

You should also add other functions (native or custom) being used in your Bricks instance besides get_post_type. This can be checked at Bricks → Settings → Custom code by clicking the Code review button.

More info on whitelisting can be found here.

Step 3

Edit a Page or a Template with Bricks.

Copy the JSON from the link below and paste to import the fully-built Section from our dev site.

Note: ACSS classes and variables are used.

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 610 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

How to display a Query Loop in 3 columns in Bricks

How to display a Query Loop in 3 columns in Bricks

This tutorial provides the builder settings and CSS codes that can be pasted in order to create a 3-columns query loop container inside Bricks Builder.
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
Parent Query Loop Object – Traversing Nested Query Loops Up in Bricks

Parent Query Loop Object – Traversing Nested Query Loops Up in Bricks

Bricks enables us to build nested query levels of unlimited levels. Here are a couple of examples: Sometimes, you might want to obtain the parent…
Categories:
Pro
Masonry for Query Loop in Bricks

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…
Categories:
Pro
Hierarchical Posts with Nested Query Loops in Bricks

Hierarchical Posts with Nested Query Loops in Bricks

Learn how to set up nested query loops in Bricks to show hierarchical posts with child posts grouped under their corresponding parent posts
Categories:
Pro
Limit the Number of Posts in a Bricks Query Loop of Relationship Type

Limit the Number of Posts in a Bricks Query Loop of Relationship Type

Updated on 12 Dec 2023 Bricks Query Loop popup does not have a control for setting the number of posts to be output when the…
Load more for Query loops in Bricks

Load more for Query loops in Bricks

Did you know that Bricks has AJAX loading for query loop posts on-click out of the box?
Categories:
Pro
Posts Grouped by Years and Months in Bricks

Posts Grouped by Years and Months in Bricks

How display posts organized by months & within years based on the published date.
Categories: