26th Jun '25
/
0 comments

Dynamically Displaying Connected Content Offer Images in Bricks using Meta Box Relationship

Consider the following scenario from a recent project I worked on.

CPT 1: project

CPT 2: content-offer

Taxonomy for Projects: remodel-typeSample term names: Backyard Cottages and DADUs, Bathrooms, Garages, Kitchens

Meta Box Relationship: Remodel Type to Content Offer (screenshot)From Term to Post

Content offer custom field: cta_image (type: Single Image)

Sample project: University District Kitchen and BathRemodel Types: Bathrooms and Kitchens

Requirement: On single project posts, get the first remodel type term, then get the first connected content offer, then get its cta_image ID.

This Pro tutorial shows how this can be done in Bricks.

Continuing with the current example, the first remodel type term is Bathrooms and the corresponding content offer is "Bathroom Pricing Guide".

Bathroom Pricing Guide's CTA image:

When done, we would use the name of the below custom function in an Image element in single project Bricks template like this:

Code can be added 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 626 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Meta Box Group’s Number Sub Field Values Sum

Meta Box Group’s Number Sub Field Values Sum

In the Bricks Facebook group a user asked: We can define a custom function that takes a Meta Box group ID, the sub field ID…
Categories:
Tags:
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:
Pro
Dynamic Source for Video Element in Bricks Using Meta Box Post Field

Dynamic Source for Video Element in Bricks Using Meta Box Post Field

This Pro tutorial provides the steps to set the source of a Bricks video element on single CPT pages to be the URL of a…
Categories:
Limiting the Query Loop Posts Output to Post IDs From a Custom Field in Bricks

Limiting the Query Loop Posts Output to Post IDs From a Custom Field in Bricks

A user asks: Recently Bricks introduced the PHP query editor that lets us modify the query parameters right within the query dialog of the builder…
Categories:
Tags:
Pro
Filtering Meta Box Cloneable Group by Select Subfield for Multiple Bricks Query Loops with Conditional Output

Filtering Meta Box Cloneable Group by Select Subfield for Multiple Bricks Query Loops with Conditional Output

In the Bricks Facebook group a user asks: Consider this cloneable Meta Box field group for a Custom Post Type called Tour: with the Tour…
Pro
Bricks Dynamic Condition – Check if today falls within 5 days before any holiday date

Bricks Dynamic Condition – Check if today falls within 5 days before any holiday date

Creating a custom condition that returns true or false depending on whether today falls within 5 days before any holiday dates selected on a Meta…
Categories:
Tags: