4th Apr '23
/
2 comments

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

Related Tutorials..

Pro
ACF User Field Bricks PHP Query

ACF User Field Bricks PHP Query

In the Bricks Facebook group a user asks: my end goal was to create a set of cards that would display the Users that are…
Categories:
Pro
Bricks Slider Images From ACF Flexible Content Sub Field

Bricks Slider Images From ACF Flexible Content Sub Field

Consider the following field group associated with Pages when using ACF Pro: "Page Fields" field group|_"Page Content" Flexible Content field|__"Layout 1" layout|___"Title" Text field|___"Layout 1…
Pro
ACF Font Awesome Field in Bricks

ACF Font Awesome Field in Bricks

We walk through using the Advanced Custom Fields: Font Awesome Field plugin for showing Font Awesome icons.
Categories:
Tags:
Pro
Bricks Dynamic Data Tag for Text-type Custom Field Value with Word Limit

Bricks Dynamic Data Tag for Text-type Custom Field Value with Word Limit

How to register a new dynamic tag for setting excerpt word limits and outputting an ellipsis (...) at the end.
Categories:
Pro
Filtering ACF Repeater Bricks Query Loop by Sub Field Value

Filtering ACF Repeater Bricks Query Loop by Sub Field Value

We look into how ACF Repeater rows output by a Bricks query loop can be filtered using the bricks/query/run PHP filter.
Categories:
Pro
Google Maps JavaScript API in Bricks

Google Maps JavaScript API in Bricks

This Pro tutorial provides the steps to show post-specific maps with custom marker content in Bricks using Google's Maps JavaScript API and Advanced Custom Fields.…
Categories:
How to create parallax effects using Rellax.js in Bricks

How to create parallax effects using Rellax.js in Bricks

This tutorial provides the JS & PHP codes that can be pasted in order to create smooth parallax effects using the Rellax.js library inside Bricks…
Categories: