0

I have a geolocation shortcode which i am adding in the post editor to display different information based on user's location, works perfectly by having it in the post page content.

How can i execute this shortcode [geolocation][/geolocation] inside a PHP file of my theme? i am using a free to modify Wordpress theme and i want to add a new <span>[geolocation][/geolocation]Information text content</span> but inside the theme's .php file, how can i do that? if i add straight the <span>[geolocation][/geolocation]Information text content</span> it will show the shortcode as text, it won't execute, please help, thanks in advance.

2 Answers 2

1

Found it: <?php echo do_shortcode( '[your shortcode goes here]' ); ?>

0

You can Execute the shortcode in php like the following

echo do_shortcode("[geolocation]");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.