apply_filters( 'generateblocks_dynamic_tag_output', $output, $options, $raw_output );
Description
Filter the Dynamic Tag content
Params
$output
– the returned output
$options
– the tag options
$raw_output
– the raw output
Basic Example #1
add_filter( 'generateblocks_dynamic_tag_output', function( $output, $options ) {
// Do something to output here.
return $output;
}, 10, 2 );
Basic Examples #2 – filtering the tag
The tag_name
eg. is saved in the $options['tag_name']
To filter a specific tag eg. {{post_title}}
add_filter( 'generateblocks_dynamic_tag_output', function( $output, $options ) {
$tag_name = $options['tag_name'] ?? '';
if ( 'post_title' === $tag_name ) {
// do something to the `{{post_title}}` tag name.
}
return $output;
}, 10, 2 );
Basic Examples #3 – filtering with a custom tag
We can define our own custom option to add to our tag:
{{the_tag my_custom_option:true}}
Then filter the $output
where the $option
is set
add_filter( 'generateblocks_dynamic_tag_output', function( $output, $options ) {
if ( ! isset( $options['my_custom_option'] ) ) {
return $output;
}
// This is my_custom_option do something to the output.
return $output;
}, 10, 2 );