JWPlayer has become my favorite video player for clients website especially after they release their official WordPress plugin. The plugin almost done all the basic things ( shortcode, custom player, etc ). It’s also integrated seamlessly with the WordPress Media library which makes your life so much easier because you can easily add the player to a post straightly from media library. However, aside from all that simple integration and setup, it lacks of documentation could cause a headache especially if you are trying to do something out of the lane.
Today, I was trying to use JWPlayer plugin to show video in a custom post type template which grab the video file from external URL ( not from Media Library ). I was thinking this would be an easy task because I could easily execute the shortcode using do_shortcode() function in WordPress. But, apparently JWPlayer plugin handle the shortcode quite different from another plugin so you have to use jwplayer_tag_callback() function instead of do_shortcode(). I don’t know the reason why they make it like that but as long as it works then it’s fine. Here is the sample code to make it clear:
//won't work
do_shortcode("[jwplayer file='http://xxx.com/xxx.mp4']");
//obviously will work
jwplayer_tag_callback("[jwplayer file='http://xxx.com/xxx.mp4']");
Thank you Rudy, This post has solved my problem. I also tried to add jwPlayer shortcode to front page but it did’not work. Very useful, Thank you.
Cheers
I want to use a shortcode of the jwPlayer on my frontpage aswell.. Where should i put the code jwplayer_tag_callback(“[jwplayer file='http://xxx.com/xxx.mp4']“);? Many Thanks
Hi Tijmen,
It’s depend on your template, most templates will use index.php file as their front page. You can find it through Appearance > Editor menu on the left.
If you are not familiar with PHP, I don’t recommend to play with this section.
Rudy