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

Related Tutorials..

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
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…
Pro
Post Data for the Current User in Bricks with Meta Box

Post Data for the Current User in Bricks with Meta Box

How to configure a query loop to output the post data of the SalesRep CPT associated with the current user.
Categories:
Pro
Meta Box Image Advanced Field Images in Bricks Query Loop

Meta Box Image Advanced Field Images in Bricks Query Loop

Updated on 3 Feb 2025 A user asked: Do you know what the best way to query an image from metabox gallery? I would like…
Categories:
Tags:
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:
Pro
MB Favorite Posts in Bricks

MB Favorite Posts in Bricks

This tutorial explores using MB Favorite Posts in Bricks, including outputting the list of favorites via a query loop.
Categories:
Pro
Meta Box Group Subfield Text’s Slug as Query Loop Item ID in Bricks

Meta Box Group Subfield Text’s Slug as Query Loop Item ID in Bricks

In the BricksLabs Facebook group a user asks: I have a metaBox custom field called 'section_title' inside a clonable metabox group called 'about_section' How can…
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: