There may come a time when you will want to display data or a function that comes in the form of a [shortcode] in a location of your website that can only be accessed through theme files.
Shortcodes can be identified by square [ ] brackets and are codes that when inserted into any page or post, generate a predefined specific functionality.
You can add WordPress shortcodes directly to WordPress theme template files using a small PHP code snippet.
To do so use the following code snippet below and add it directly to any WordPress theme file where you wish to display the shortcode content.
Replace [shortcode] with your own shortcode.
<?php echo do_shortcode("[shortcode]"); ?>
Make sure you make backup copies of the files you are going to modify. Ideally, you will want to have a child theme installed.
Code not working? Please contact us.
Also See: What is a WordPress child theme?