Custom Dynamic Data Tags in Bricks

It is possible in Bricks to output the value returned by any function via

{echo:functionName}

whilst passing arguments if needed.

Sometimes you may want to add your own items to the "Select dynamic data" list since it is more convenient/easier.

This Pro tutorial provides one way to do this. We shall register a "Parent link" dynamic data tag which when selected sets the hyperlink URL to the parent post/Page of the current post/loop item and if a parent is not present, to #.

Prerequisite

Bricks child theme must be the active theme.

Step 1

Copy

/wp-content/themes/bricks/includes/integrations/dynamic-data/providers.php

to

/wp-content/themes/bricks-child/providers.php

Replace

$classname = 'Bricks\Integrations\Dynamic_Data\Providers\Provider_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $provider ) ) );

with

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 526 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Conditional Output Based on ACF Date Field in Bricks

Conditional Output Based on ACF Date Field in Bricks

Updated on 1 Aug 2024 Looking to have a Section or other elements in Bricks rendered on the frontend only if today's date is before…
Categories:
Month-based Background Image in Bricks

Month-based Background Image in Bricks

How to have different background images for an element for different quarters in a year.
Categories:
Conditionally Outputting Elements Only for Posts That Have a Specific Taxonomy Term

Conditionally Outputting Elements Only for Posts That Have a Specific Taxonomy Term

Using the core WordPress has_term() function for checking if the current post has a specific term of a given taxonomy.
Categories:
Pro
Primary Term Name and Link in Bricks when using Rank Math

Primary Term Name and Link in Bricks when using Rank Math

One of the features of the Rank Math SEO plugin is the ability to mark a term like category or product category as primary. See…
Pro
Condition to Check if the Current Category Has At Least One Child

Condition to Check if the Current Category Has At Least One Child

Looking to render an element in the category archive Bricks template only if the category of the current category archive page is a parent? This…
Categories:
Pro
“Pro” Category Ribbon for Posts in Bricks

“Pro” Category Ribbon for Posts in Bricks

This Pro tutorial provides the steps to show a "Pro" ribbon for posts that are categorized under the "Pro" category when using Bricks builder. Step…
Categories:
Pro
Month and Day Condition in Bricks

Month and Day Condition in Bricks

This Pro tutorial shows how we can define a custom function that takes in a month in the three-letter format (like Dec) and a day…
Categories: