WordPress shortcode is very useful while creating new posts or pages. It is a nifty way to perform certain tasks in the post. For instance, if you want to add a youtube video or image gallery then WordPress shortcodes are quite useful.
Many plugins provide their own shortcodes for displaying certain content or performing some tasks. However, you might require the same plugin functionality in a theme file. Since the shortcode tag is not a standard one so you cannot write it in the PHP file. WordPress provides a wrapper function to make this shortcode work in the PHP file.
Just paste the following PHP code at the place where you want that shortcode to work.
<?php // Use shortcode in a PHP file (outside the post editor). do_shortcode('[your_own_shotcode]'); ?>
It’s an awesome way to use a shortcode inside the template files. Hope it helps.