Parsing shortcodes in WordPress template files

To include a known shortcode in a custom page/post template file as part of the content, you need to use do_shortcode() :

echo do_shortcode( "[a-registered-shortcode-name]" );

The function do_shortcode() parses shortcodes with their registered hooks in the content and return the content with the parsed shortcodes output. Below example use do_shortcode() to parse multiple shortcodes in a piece of content.

echo do_shortcode( "<p>Shortcode example 1: ['shortcode-name1']</p><p>Shortcode example 2:['shortcode-name2']</p>" );

If you write the shortcode string in the article content just like you what you do in WordPress edit page, it will not be parsed.

<!-- The shortcode below is just a plain text in the page/post template -->
<p>
    ["a-registered-shortcode-name"]
</p>

When editing a page/post in WordPress, the shortcode string works because it will be processed by the the_content() in a template file when it is displayed. the_content() will call do_shortcode() to process the shortcodes inside the content.