WordPress plugins not using shortcodes: how to fix

Shortcode support has been in WordPress since version 2.5, but still many plugin authors are not filtering post content for shortcodes, leaving blog owners scratching their heads and wondering why the plugin is not working as expected. I’ve recently tripped over this twice while working on a new site, so while waiting for the plugin author(s) to add official shortcode support, here is a way to add the functionality yourself.

Look in the plugin code for where the $variable->post_content is first used. It should be near a function call like get_post($id);

$post = get_post($id);
$content = $post->post_content;

Now add this line (matching the variable names of course):
$content = do_shortcode($content);

That will parse the content of the post, replacing any shortcodes with their replacement values. After that the plugin should be able to do it’s work as expected.

John Holt

I’m a software engineer and web designer in Fort Pierce, Florida (winter) and Franklin, New Hampshire (summer). Super Blog Me is a space where I can brainstorm my ideas on WordPress development, interface design and other things I do with my life.

Leave a Reply

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