Now days youtube is a biggest video search and play engine. so gradually it is need to use youtube video in our wordpress post. for adding youtube video in your wordpress posts there are many plugins. also you can embed youtube video on your blogger blog or blogspot blog but today i am sharing some code which is very helpful for add youtube video to wordpress posts without any kinds of plugins. for this please follow some steps very carefully:
(Please backup your sites file and database before editing)
1. At first go to your wordpress sites dashboard.
2. Now select your theme which theme you want to edit.
3. Now open your themes 'functions.php' file.
4. Copy bellow code:
6. Now paste this code in your wordpress blog post.
For following this article you can add youtube video to wordpress posts and if you want to know more about wordpress and blogger or blogspot then you can visit my another article in this blog.
(Please backup your sites file and database before editing)
1. At first go to your wordpress sites dashboard.
2. Now select your theme which theme you want to edit.
3. Now open your themes 'functions.php' file.
4. Copy bellow code:
/*5. Now paste this code in 'functions.php' file and save and close it.
Shortcode to display youtube thumbnail on your wordpress blog.
Usage:
[youtube_thumb id="VIDEO_ID" img="0" align="left"]
VIDEO_ID= Youtube video id
img=0,1,2 or 3
align= left,right,center
*/
function wp_youtube_video_thumbnail($atts) {
extract(shortcode_atts(array(
'id' => '',
'img' => '0',
'align'=>'left'
), $atts));
$align_class='align'.$align;
return '<img src="http://img.youtube.com/vi/'.$id.'/'.$img.'.jpg" alt="" class="'.$align_class.'" />';
}
add_shortcode('youtube_thumb', 'wp_youtube_video_thumbnail');
6. Now paste this code in your wordpress blog post.
[youtube_thumb id="rNWeBVBqo2c" img="0" align="center"](Change 'rNWeBVBqo2c' with your video id)
For following this article you can add youtube video to wordpress posts and if you want to know more about wordpress and blogger or blogspot then you can visit my another article in this blog.













