Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

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.