WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to get VideoJS plugin to work in a Widget.
I tried to add a PHP widget and write, as it said in the manual:

[video mp4="http://video-js.zencoder.com/oceans-clip.mp4"]

But it just shows the code as is, any ideas?

share|improve this question
up vote 1 down vote accepted

To display shortcodes in widgets , use a regular text widget, and add this line to your theme's functions.php file:

// Use shortcodes in text widgets.
add_filter('widget_text', 'do_shortcode');

This tells WordPress to render the shortcodes in widgets.

and if you want to call your shortcode by php you can use do_shortcode() function

// Use shortcode in a PHP file (outside the post editor).
do_shortcode('[video mp4="http://video-js.zencoder.com/oceans-clip.mp4"]');

To get a better understanding of shortcodes check out this tutorial which covers: What shortcodes are, How to use shortcodes, ,How to define your own. and How to use them in widgets.

Hope this helps

share|improve this answer

You can't use a WordPress shortcode in PHP code. You'll need to find the corresponding function and use that.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.