I have the following code in my WordPress theme’s functions.php
file:
// Variable for structure name
$structure_name = "P4O10";
// Shortcode function
function show_structure_name($atts) {
global $structure_name;
return $structure_name;
}
// Register shortcode
add_shortcode('STRUCTURE', 'show_structure_name');
This code defines a variable $structure_name
and creates a shortcode [STRUCTURE]
that outputs the value of $structure_name
.
In Elementor’s Text Editor, I can use [STRUCTURE]
, and it correctly displays “P4O10”. However, when using the Crocoblock Woo Page Builder, [STRUCTURE]
does not get replaced, and the shortcode remains as-is.
Since the structure name (currently “P4O10”) changes every month, I don’t want to manually update it in every subpage that uses it.
My questions are:
-
Is there a way to make the
[STRUCTURE]
shortcode work with the Crocoblock Woo Page Builder? -
Alternatively, is there a better solution, like using a global variable that can be accessed in both Elementor and Woo Page Builder, without needing to use a shortcode?
I would appreciate any suggestions or solutions to this problem. Thank you!