How to use WordPress shortcodes in template files

By default, WordPress template files are unable to execute the shortcodes. However, we can easily fix this issue by using do_shortcode() function provided by WordPress. To use shortcode in WordPress template file use the following code.

<?php echo do_shortcode("[your-shortcode]"); ?>

And, don’t forget to replace ‘your-shortcode’ with the shortcode you want to use.

See Also: How to Use Shortcodes in WordPress Text Widgets

 

0 Comments

Leave a Comment.