Home  »  ArticlesGuidesHow ToSoftwareTechnologyTips   »   How to use WordPress Shortcodes in the Template

How to use WordPress Shortcodes in the Template

WordPress shortcodes are powerful pieces of text in square brackets added to the content area of a WordPress post or page to invoke some non-standard functionality.

This could be as simple as showing an icon in place or entire photo galleries. The options are virtually endless.

Just like the surrounding world around us, WordPress is not a perfect place and with that in mind, the content areas of posts or pages may not always be the right place to put WordPress shortcodes.

The only other option may be to place it directly into your WordPress theme PHP template. The good news is that WordPress anticipated this and has provided a function that can be used to do this.

To invoke a shortcode in a PHP template simply use the following function with the desired shortcode as its parameter:

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

And that’s it your tip of the day.

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.