All posts in Wordpress

Execute JWPlayer shortcode in WordPress custom template

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 link='http://xxx.com/xxx.mp4']");
 
//obviously will work
jwplayer_tag_callback("[jwplayer link='http://xxx.com/xxx.mp4']");

Change wordpress default email and name

Actually you can find this solution easily in Google. However, I’ll put it in my blog just because I am lazy to find it again.

So wordpress has default email address and name which are “WordPress” as the name, wordpress@yourdomain.com as the email. To change it you can use plugin or put these wordpress action to your functions.php file in themes folder :

add_filter('wp_mail_from', 'new_mail_from');
add_filter('wp_mail_from_name', 'new_mail_from_name');
 
function new_mail_from($old) {
 return 'no-reply@rudylee.com';
}
 
function new_mail_from_name($old) {
 return 'Rudy';
}

Just change the email address and name to your’s. Hope it works, cheers.

Make wordpress using the latest jQuery

I just copied this from another website, put it here just in case that I forgot.

if( !is_admin()){
   wp_deregister_script('jquery');
   wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"), false, '');
   wp_enqueue_script('jquery');
}

Put this snippet to functions.php file in your theme folder ( eg : wp-content/theme/whatever/functions.php )