RUSSEL86

How to get youtube video ID from youtube video link

Aug 23rd, 2015
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. first make metabox id by video_iframe for youtube link for user then you can use this code       
  2.  
  3. <?php $video_iframe = get_post_meta($post->ID, 'video_iframe', true); 
  4. $YouTubeVideo = '';           
  5. if(!empty($video_iframe)){           
  6. $video_link = explode('youtube.com/watch?v=', $video_iframe); 
  7. }           
  8. $YouTubeVideo = $video_link[1]; 
  9. ?>
  10.  
  11. <iframe  src="http://www.youtube.com/embed/<?php echo $YouTubeVideo; ?>?rel=0&amp;amp;theme=light&amp;amp;iv_load_policy=3&amp;amp;showinfo=0&amp;amp;hd=1&amp;amp;autohide=1&amp;amp;color=white&amp;amp;autoplay=1" frameborder="0" allowfullscreen ></iframe>
  12.  
  13.  
  14. // ** for youtube thumbnail follow this link http://stackoverflow.com/questions/2068344/how-do-i-get-a-youtube-video-thumbnail-from-the-youtube-api
Advertisement
Add Comment
Please, Sign In to add comment