How to display a shortcode in a WordPress template

Use do_shortcode() to render plugin shortcodes inside WordPress theme template files. Working PHP snippet, why it's needed, and when to use it safely.

You have a plugin shortcode and you want it to display in a WordPress template file. Here is how to do it with a simple function.

Replace [shortcode] with the shortcode that you want to display and the job is done.

echo do_shortcode( '[shortcode]' );