Related Posts using ACF Post Object in Bricks

Updated on 20 Jun 2024

This Pro tutorial provides the steps to modify the query of a Bricks Posts element or a Block on which query loop has been enabled to limit the posts to only those that are related to the current single post via an ACF Post Object custom field.

Field being populated when editing a Post:

On the front end:

We shall ensure that the

  • Section gets output only if there is at least one related post for the current post
  • "Related Posts" heading is output if there is only one related post and "Related Posts" heading if there is more than one related post

Step 1

Create the ACF field group having a Post Object type of field named related_posts.

Set "Filter by Post Type" to your desired post type(s) items that you want to set a relationship to.

Set it to appear on the post type of your choice.

In this example, both of the above are set to post.

Ensure that the Return Format is set to Post ID.

Enable "Select Multiple".

Step 2

Edit your posts and select 1 or more related posts for your posts.

Step 3

Edit your single post template with Bricks.

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..

ACF Repeater Sub Field Values as Tabs in Bricks

ACF Repeater Sub Field Values as Tabs in Bricks

Bricks' query loop supports ACF Repeaters and Meta Box Groups out of the box besides posts, users and terms. This tutorial shows how we can…
Categories:
Tags:
How to populate a map with dynamic markers from a CPT using ACF in Bricks (PART 2)

How to populate a map with dynamic markers from a CPT using ACF in Bricks (PART 2)

This tutorial provides the PHP & JS codes that can be pasted in order to create a flying effect on map markers each time your…
Color Custom Field as Section Background Color on Category/Term Archives in Bricks

Color Custom Field as Section Background Color on Category/Term Archives in Bricks

How to use a color from a taxonomy term custom field for as the hero section background color on archive pages.
Categories:
Tags:
Pro
Querying Posts by ACF Date Sub Field in Bricks

Querying Posts by ACF Date Sub Field in Bricks

Updated on 17 Nov 2023. This Pro tutorial shows how we can set post__in query parameter of a query loop in Bricks to an array…
Categories:
Tags:
Pro
Querying Posts by Date/Datetime Custom Fields in Bricks

Querying Posts by Date/Datetime Custom Fields in Bricks

This Pro tutorial shows how to configure ACF and Meta Box to query posts in Bricks by custom field(s) of the type Date/Date Time Picker…
Categories:
Tags:
Pro
Bidirectional Relationship between a CPT and a Taxonomy of another CPT using ACF in Bricks

Bidirectional Relationship between a CPT and a Taxonomy of another CPT using ACF in Bricks

A couple of members asked: I have a cpt called "Markets" aand a cpt "tools". Tools have a taxonomy "tools group". How can i create…
Pro
ACF Flexible Content Field – Layout Labels and Sub Field Labels

ACF Flexible Content Field – Layout Labels and Sub Field Labels

How to output the text of layout labels and/or sub field labels using the Flexible Content field of ACF Pro.
Categories: