Sometimes you might have to add a shortcode in WordPress PHP template file to accomplish certain functions.
Adding a shortcode directly to a WordPress template file will not work. We need to add the shortcode inside opening and closing PHP tags and invoke it with a special function as follows.
<?php echo do_shortcode('[name_of_shortcode]'); ?>
Now you can insert the shortcode inside a WordPress template file.