I'd like to be able to take a youtube video from the most recent post in a category and display it on my homepage. Check out my site: http://beachief.com/. There's a video on the homepage, but its hard coded in there. I can get the attachment ID with this code:
<?php global $wpdb; $attachment_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post->ID' AND post_status = 'inherit' AND post_type='attachment' ORDER BY post_date DESC LIMIT 1"); ?>
and display a video with this code:
<iframe width="305" height="250" src="http://www.youtube.com/embed/YFbLRZCExBk" frameborder="0" allowfullscreen></iframe>
But how can I display the video the ID is pointing to?
I'm looking for something like this:
<iframe width="305" height="250" src="<?php echo wp_get_attachment_url($attachment_id); ?>" frameborder="0" allowfullscreen></iframe>
but that doesn't work, because its not giving me the embed url. How can I get the video's embed url?