1

I am trying to have all my posts with post_format set as video, have said video as the featured image. Here is what I am working with thus far but I need some help:

    if($post_format == 'video') {

    if(get_post_meta($post->ID, 'video_site_url', true)) the_post_thumbnail($post->ID, 'video_site_url');        
        echo '<div class="video-containers single_item">'.wp_oembed_get(get_post_meta($post->ID, 'video_site_url', true)).'</div>';
}

Right now I'm using a YouTube's iframe to embed the video into my post and that seems to be working quite well.

1
  • Image is not a video. So technically "featured image" should be an "image". Try this plugin if you want to get YouTube image and set it as featured image.
    – Rain Man
    Aug 24, 2016 at 19:12

1 Answer 1

1

Well this is not exactly a WordPress problem / solution.

First you have to either get the video id from the video_site_url post meta or save the YouTube video id in it's own post meta field, maybe youtube_video_id.

Next you can get the thumbnail using one of these url

http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg

Read this SO answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.