Reputation: 519
I'm trying to let users post a video on one our sites with text beneath it. Is there a way display the YouTube thumbnail image as a user's post thumbnail.
Example:
I post a YouTube video on the site: IMAGE LINK
Using HTML/PHP I pull in the posts on to my website using the below code:
<?php
$posts = get_posts('cat=3');
foreach ($posts as $post) : setup_postdata( $post );
?>
<?php the_date(); echo "<br />"; ?>
<?php the_title(); ?>
<?php endforeach; ?>
I want to load the image/video and then the title of the post. Not the date or any other content. How can this be done?
Then how can I make that thumbnail a link to go to the actual post?
Upvotes: 0
Views: 7049
Reputation: 519
The above answer got me to this part. I figured Id share my corrected code.
<?php
$posts = get_posts('cat=3');
foreach ($posts as $post) : setup_postdata( $post );
?>
<img src="http://img.youtube.com/vi/<?php echo get_post_meta($post->ID, 'video', true); ?>/0.jpg" alt="<?php the_title(); ?>" width="200" height="150">
<br />
<?php the_title(); ?>
<?php endforeach; ?>
Upvotes: 4
Reputation: 1527
You could grab the video id by using a custom field and place it inside the Video Thumbnail URL to get the video thumbnail.
Upvotes: 1