Is there a way to parse shortcodes in PHP?

Many plugins don’t provide a documented way to access their functions from within PHP (e.g. when building a custom theme), but only shortcodes to insert in posts.

Is there a standard way of executing shortcode from within PHP as if it were part of the content? Like so (this is made up):

$gallery_html = execute_shortcode("{gallery}");  //  this would return the HTML  
                                                 //  that the gallery plugin returns
                                                 // in the context of the current post

Related posts

Leave a Reply

1 comment