How to Insert a Shortcode into a WordPress Template

When it comes to getting dynamic information to display on a WordPress page, there are two basic options:

1. Super simple: Using shortcodes in the text editor

2. Kinda Hard: Customizing a WordPress template using PHP

But sometimes you actually need to make use of both options. Is it possible to use a WordPress shortcode in a PHP template file? The answer is, yes. And here’s how:

echo apply_filters('the_content',"[shortcode]Content[/shortcode]");

That’s it. Seriously. Not kidding.

Leave a Reply

Your email address will not be published. Required fields are marked *