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

Related Tutorials..

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
User Role Conditional Output in Bricks

User Role Conditional Output in Bricks

This Pro tutorial provides the steps to output elements based on their CSS class to users of the specified role in WordPress when using Bricks…
Categories:
Conditional Output on the First Page of Archives in Bricks

Conditional Output on the First Page of Archives in Bricks

How to output an element on an archive page only if we're on the first page of the archive.
Categories:
Pro
Meta Box Related Project’s Featured Image URL on Single Reviews

Meta Box Related Project’s Featured Image URL on Single Reviews

Updated on 26 Jun 2025 In a recent website I worked on, a requirement was to get the URL of the featured image of a…
Pro
Nested Meta Box Query Loop Inside a CPT Query Loop in Bricks

Nested Meta Box Query Loop Inside a CPT Query Loop in Bricks

This Pro tutorial provides the steps for setting up a cloneable Meta Box group query inside a CPT query in Bricks. Scenario: CPT: course Meta…
Categories:
Create A Customizable AJAX Add To Cart Button In Bricks Builder

Create A Customizable AJAX Add To Cart Button In Bricks Builder

In Bricks, you can simply create an Add To Cart button from a dynamic data / function {woo_add_to_cart}. This button supports AJAX as well if…
Pro
Adding FAQ page Schema with SlimSeo Schema & Meta Box

Adding FAQ page Schema with SlimSeo Schema & Meta Box

SlimSeo Schema is a plugin by the people behind both SlimSEO & Meta Box. It takes care of adding all the page schema across your…
Categories: