Related Posts using Meta Box in Bricks

Updated on 12 Apr 2024

This Pro tutorial provides the steps to show posts set as related to the current single post via a Meta Box Post-type of field in Bricks.

Note

This can be applied to entries of any post type, not just post.

Step 1

Create a custom field group having a Post type of field.

Tick "Multiple".

Step 2

Edit your entries and selected the related posts.

Step 3

Edit your single post template with Bricks.

When done the structure should look like this:

Add a Section and inside its Container, a Related Post h2 heading and another Related Posts h2 heading.

We shall apply conditions on these headings to output them depending on whether there's 1 related post or more than 1.

Add a Container and inside it, a Block.

Enable query loop on the Block.

Click the loop icon and enable PHP query editor.

Paste:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 524 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Display 3 Category-related Posts and Supplement with the Latest Published Posts if Necessary

Display 3 Category-related Posts and Supplement with the Latest Published Posts if Necessary

In the Bricks Facebook group a user asks: Show latest 3 related posts based on category and IF THERE ARE NOT ENOUGH, fill the empty…
Pro
How to Inject a Different Type of Post in Bricks Query Loop

How to Inject a Different Type of Post in Bricks Query Loop

Updated on 26 Aug 2024 A user asks: Hello, I'd like to inject a CPT post card inside of a Bricks query loop of a different CPT…
Pro
Random Row from ACF Repeater in Bricks

Random Row from ACF Repeater in Bricks

In the past, we shared how the first row of a ACF Repeater can be output in a Bricks query loop here. This Pro tutorial…