I’m following the documentation over here at this link to support Bricks builder for my WordPress plugin. Currently, I’m using child theme’s functions.php to make it work.
Here’s the code.
add_filter( 'bricks/dynamic_data/render_tag', 'get_my_tag_value', 10, 3 );
function get_my_tag_value( $tag, $post, $context = 'text' ) {
// $tag is the tag name without the curly braces
// Only look for dynamic tag my_dd_tag
if ( $tag !== 'my_dd_tag' ) {
return $tag;
}
// Do your custom logic here, you should define run_my_dd_tag_logic() function
$value = run_my_dd_tag_logic();
return $value;
}
function run_my_dd_tag_logic() {
// Do your custom logic here
$my_value = 'My dynamic data value:';
return $my_value;
}
add_filter( 'bricks/dynamic_data/render_content', 'render_my_tag', 10, 3 );
add_filter( 'bricks/frontend/render_data', 'render_my_tag', 10, 2 );
function render_my_tag( $content, $post, $context = 'text' ) {
// $content might consists of HTML and other dynamic tags
// Only look for dynamic tag {my_dd_tag}
if ( strpos( $content, '{my_dd_tag}' ) === false ) {
return $content;
}
// Do your custom logic here, you should define run_my_dd_tag_logic() function
$my_value = run_my_dd_tag_logic();
// Replace the tag with the value you want to display
$content = str_replace( '{my_dd_tag}', $my_value, $content );
return $content;
}
The issue is that $content argument passed on render_my_tag function does not contain any value.