The Daily Shaarli

All links of one day in a single page.


How do I call functions from my Plugin in WP template?

In order to execute shortcode inside a template, use the function do_shortcode('[my-shortcode-handle]'). Your shortcode needs to be registered as like normal (see WordPress codex on shortcode API) before you can use this in the template. Any attributes, inside content, etc. should be in there as well.

echo do_shortcode( '[my-shortcode foo="bar"]Shortcode content[/my-shortcode]' );

Also, remember to echo the return (or at least assign it to a variable), since it only returns the shortcode's output.