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

Related Tutorials..

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:
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
Meta Box/ACF Images Staggered Grid Gallery in Bricks

Meta Box/ACF Images Staggered Grid Gallery in Bricks

Showing images from two Gallery-type of ACF or Image Advanced-type of Meta Box fields in a staggered grid layout.
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…
Output HappyFiles Folders in Metabox Select-Field

Output HappyFiles Folders in Metabox Select-Field

This tutorial is part of a series where I'm gonna show you how to output custom HappyFiles Galleries and Sliders. Part one will cover a…
Categories:
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
Filtering Cloneable Meta Box Group by Sub Field Value in Bricks

Filtering Cloneable Meta Box Group by Sub Field Value in Bricks

This Pro tutorial provides the steps to filter the rows of a Meta Box cloneable group to only those that have a date custom field…