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

Related Tutorials..

Pro
Conditionally outputting an element in a Query Loop based on date-type custom field

Conditionally outputting an element in a Query Loop based on date-type custom field

This Pro tutorial shows how to output an element in a Bricks' query loop only if the value of a date-type of custom field for…
Categories:
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
Sort Posts by Meta Box Group Sub Field in Bricks

Sort Posts by Meta Box Group Sub Field in Bricks

This Pro tutorial provides the steps to order posts in Bricks by the value of a Number-type of sub field that is inside a Meta…
Filtering Bricks Posts Query Loop by Meta Box Group’s Radio Subfield Value

Filtering Bricks Posts Query Loop by Meta Box Group’s Radio Subfield Value

In the past we showed how a Bricks posts query loop can be filtered by Meta Box group's subfield of types text/number and Datepicker here.…
Categories:
Pro
Meta Box Checkbox List Query Type in Bricks

Meta Box Checkbox List Query Type in Bricks

This Pro tutorial provides the steps to add a new query type in Bricks builder for displaying the values of a Checkbox List type of…
Categories:
Pro
Dynamic Post-specific Templates in Bricks using Meta Box/ACF Select Field

Dynamic Post-specific Templates in Bricks using Meta Box/ACF Select Field

Update on 23 Aug 2023: Added steps for ACF. Bricks builder v1.8.4 introduced an pretty useful filter called bricks/active_templates that flew under the radar. This…