Hello,
Access to my website is in Private Content.
I have added a function in my child theme’s functions.php file, at the bottom. After the function ends, I have defined a variable, $distance. When I add echo $distance; to the bottom of the functions.php page, the variable’s value displays at the top of my website. This shows that the function and variable are working correctly. However, when I edit a page (testing on a page called VARIABLE TEST) and add an Enfold “Code Block” with the content <?php echo $distance; ?> , the variable’s value does not display. How can I properly display the value of a variable within an Enfold “Code Block” ?
Thanks!
Hey,
I commented out
echo $distance;
and added following code in functions.php file of your child theme
function distance_sc(){
global $distance;
$output = "<span class='distance-info'>". $distance . "</span>";
return $output;
}
add_shortcode( 'distance', 'distance_sc' );
You can use following shortcode to display your variable
[distance]
Best regards,
Yigit
YES! THANK YOU! I’m really not sure how you know that wizardry code ;) But that worked perfectly :) :) :) Seriously, thank you so much, you just saved me either hours and hours or a lot of hair pulling!!! You’re the best. This ticket is safe to close :)
Hi,
I’m glad you were able to get this solved. If you need additional help, please let us know here in the forums.
Best regards,
Jordan Shannon