Support » Plugins » Plug-in's shortcode works in post but not with do_shortcode

  • I have started using the Store Locator plug-in (, and it looks very promising.

    I have one problem. If I enter its shortcode (“[STORE-LOCATOR]”) in the content of a post/page it is processed correctly. But if I enter it in a custom template with

    <?php echo do_shortcode('[STORE-LOCATOR]'); ?>

    it does not work, and just outputs the [STORE-LOCATOR] text. I found a mention of this same problem on the Stack Overflow tech site, but nowhere else.

    I am able to use do_shortcode with my own custom shortcodes, added in my functions.php.

    I’m not an expert in WP sequencing, but it seems like the plug-in is not loaded/initialized at the time it executes do_shortcode, but is loaded by the time it processes the $content. Is there a way to adjust this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Michael


    Forum Moderator

    some plugins don’t use real shortcode, but some preg-replace to locate and process the stuff within the square brackets.

    ‘do_shortcode()’ will not work in these cases.

    check the plugin code, if this is the case.

    you might be able to find a function to call directly;
    or contact the plugin author.

    Thanks for the response. Yes you’re right — I searched the plug-in source code and it is doing custom preg replacement of the tag in the post content (not the template). It also relies on having the tag in the post content so it can detect and insert content to the <head> of the page. It’s not doing a real shortcode.

    The plug-in has its own mechanism for skinning, so I’ll probably work within that structure instead.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Plug-in's shortcode works in post but not with do_shortcode’ is closed to new replies.