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 I used the dynamic tag to return the value of section_title with all the spaces replaced with dashes.

e.g. if the section title was 'section one', I want to return 'section-one' with the echo tag.

The reason is to dynamically add IDs to each section in Bricks query loop via attributes.

This Pro tutorial provides the steps to set the id of each item of a Meta Box Group query to the slug of a text-type subfield's value.

Consider this field group for a Page:

about_section field being populated:

Bricks editor:

Section JSON

For the query loop-enabled element add id attribute like this:

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

Instant access to 390+ Bricks code tutorials with BricksLabs Pro