Hey! I’ve got a promo code that appears many times on my website. Is it possible to set the promo code up as a variable and call it within a Rich Text block?
I’ve tried it using a shortcode (In the rich text) that calls the variable, but it doesnt render as anything when I save the bricks page and preview it. Any possible ways to do this?
thx!
Do you have ACF? If so you could create an Options page, add a field and put the code there. Then fetch it with dynamic data tag.
Or you could just create a template, with only a div / text block or similar, and use the shortcode for it (all Bricks templates can be called with the Brick shortcode.
Or create a template and make it a global element. Then just use that element.
For the template options, I wouldn’t be able to just insert that string into a text block though right? Because the promo code shows up in different paragraphs here and there.
Is there a way to do this manually? How can I call in a variable inside a Rich Text element or doesnt that not work? I installed a WordPress plugin that creates global variables and you call it by referencing a shortcode or php code assigned to the variable.
No ACF, would consider it but looks like subscription?
EDIT: ok I just learned about dynamic data. Maybe I’m getting close. I chose PHP function but I’m not sure if I’m formatting it correctly. This is the PHP code the global variable plugin has created for me to use: <?php echo $GLOBALS['cgv']['promo '] ?>
I’ve added it to the rich text as: {$GLOBALS(‘cgv’)(‘promo’)}
Am I close?? Not working as of yet. Just renders that last code as is and not the variable. thx
Ha! The shortcode works now. I guess I was over complicating this. Thank you!
I love bricks! This has been the most fun and powerful way to build sites. I love how I can integrate my own css so easily and I feel like I know what the visual building is doing on the backend layout/code wise. So good.