10th Mar '23
/
3 comments

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 610 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
How to programmatically add a class to an element in Bricks

How to programmatically add a class to an element in Bricks

This Pro tutorial shows how a dynamic class can be added to a query loop element in Bricks programmatically. Let's take an example where posts…
Pro
Previous Two Posts in Bricks Query Loop

Previous Two Posts in Bricks Query Loop

This Pro tutorial shows how we can modify the parameters of a Bricks query to limit the posts to the previous two whilst cycling to…
Pro
Restrict Content Pro in Bricks

Restrict Content Pro in Bricks

This Pro tutorial provides the steps to restrict Pages and individual elements like Sections in Bricks depending on whether the current user has any active…