Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

do_shortcode not working

Tags:

I've been stuck on this for a while. I'm working on a wordpress site where I wrote the theme from scratch, I use php calls to get the wordpress functionality that I need in certain sections.

I'm trying to use a plugin, but calling it via

echo do_shortcode('[STORE-LOCATOR]');

just isnt working. Even when I switch to the default template and post that code, it still doesnt work. It simply echoes "[STORE-LOCATOR]"

Any help would be greatly appreciated.

like image 731
sjobe Avatar asked Mar 12 '11 14:03

sjobe


People also ask

Why is shortcode not working?

Check whether the plugin providing the shortcode is active or not. If it is not active, then the shortcode won't work. 2. Your theme is outputting the post content without applying the needed filters to it.

What is Do_shortcode in WordPress?

The WordPress do_shortcode function makes it easy to include shortcodes directly in your theme's template files. All you need to do is include the shortcode inside of the do_shortcode function and echo the function in the template location where you want the shortcode to appear.

How do you add a shortcode in HTML?

Press the brackets icon to display the shortcode. Then, copy the shortcode, as you'll need it later. Go to Appearance -> Customize, to go to the Customizer and insert the custom HTML in the page you want. Create a new section that will be dedicated to the custom HTML you want to insert in the page.


1 Answers

[STORE-LOCATOR] is probably not a 'shortcode' in WordPress sense.

I encountered this on different plugin, Stream media player. They use the same syntax as shortcodes, but they are actually not.

Try using:

echo apply_filters( 'the_content',' [STORE-LOCATOR] ');

instead of do_shortcode, and see if it helps.

like image 152
birdsonwire Avatar answered Nov 04 '22 14:11

birdsonwire