15th Jul '25
/
2 comments

Getting Field Values from a Connected CPT when using Meta Box Relationship in Bricks

This Pro tutorial provides the steps to conditionally render elements in a single template of a CPT depending on the value of a

  1. regular custom field
  2. subfield of a cloneable Group field

of a CPT connected to the current post via a Meta Box relationship.

Here's the scenario we are working with:

CPT 1: Award WinnerCPT 2: Property Development

Relationship: Award Winners -- Property Development

An Award Winner post will only be related/connected to one Property Development post at the most.

Custom fields for Property Development:

  • property_development_nearby_institutions_option (Select field with these choices: Disabled and Enabled)
  • property_development_facilities_group (Group field set to cloneable)
    • property_development_facility_name (Text subfield)

View/template in question: Single Award Winner post pages.

Requirements:

  1. Create a custom function that returns the value of the given field of the Property Development post that's connected to the current Award Winner post.
  2. Create a custom function that returns a boolean (true or false) depending on whether there is at least one row of the given subfield of the given group field of the Property Development post that's connected to the current Award Winner post.

Step 1

Add the following in child theme's functions.php (w/o the opening PHP tag) or a code snippets plugin:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 633 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Bricks Query Loop – Checking for Current Post on Single Posts

Bricks Query Loop – Checking for Current Post on Single Posts

In a query loop on single post view, how to make the 'current post 'item styled differently.
Categories:
Custom Image Field Avatar in WordPress

Custom Image Field Avatar in WordPress

Learn how to use a Meta Box image field value as the author profile image on single post pages in WordPress/Bricks.
Categories:
Tags:
Pro
City-based and Country-based Conditional Output in Bricks

City-based and Country-based Conditional Output in Bricks

This Pro tutorial provides the steps to render a Bricks element only if the visitor is from the specified country or city. Note: Caching may…
Categories:
Pro
Conditional Rendering of ACF Repeater Rows Based on True / False Sub Field in Bricks

Conditional Rendering of ACF Repeater Rows Based on True / False Sub Field in Bricks

This Pro tutorial provides the steps to modify a ACF Repeater query loop to only output the rows for which a True / False type…
Categories:
Pro
Checking if the current Page/Post has Children i.e. is a Parent in Bricks

Checking if the current Page/Post has Children i.e. is a Parent in Bricks

Shows how we can check whether the current Page or Post (of any hierarchical post type) is a parent
Categories:
Pro
Meta Box Color Picker to CSS Custom Property Workflow in Bricks

Meta Box Color Picker to CSS Custom Property Workflow in Bricks

This Pro tutorial provides the steps to declare a custom property (CSS variable) whose value is equal to the post-specific color set via a custom…
Categories:
Tags:
Pro
Meta Box Relationship Posts Filtered by a Taxonomy Term in Bricks

Meta Box Relationship Posts Filtered by a Taxonomy Term in Bricks

Updated on 17 Feb 2025 In the Inner Circle a user asks: Hello, I have a relationship made in metabox between two Post Types “Travel”…
Categories: