In this tutorial, you’ll learn how to execute WordPress shortcodes in templates.
As you may know, WordPress shortcodes won’t execute if you just copy and paste them in .php templates directly.
You need to pass them to
do_shortcode function first.
Hi, I'm Renat 👋
E.g. if you’re trying to display a map in a template you can do this. Replace the word ‘map’ with your own shortcode and paste the code below into your file.
<?php echo do_shortcode( '[map]' ); ?>
That’s it, it will now execute your shortcode in WordPress template file.
If you find this post useful, please let me know in the comments below.
Want to share this with your friends?
PS: make sure you check other WordPress tutorials, e.g. Split functions.php into multiple files in WordPress, load Google Fonts via functions.php in WordPress and download my plugin that improves your WordPress SEO & Performance.