hi there 🙂
If you enable the Auto Embeds, also known as oEmbed, (Administration > Settings > Media SubPanel – /wp-admin/options-media.php
), the YouTube link should automatically be converted to a video.
Otherwise, it’s a matter of echoing the normal embed code and insert your custom field in the middle:
$youtube = get_post_meta($post->ID, 'video_url', true);
echo '<object width="560" height="315"><param name="movie" value="' . $youtube . '?version=3&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="' . $youtube . '?version=3&hl=en_US" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object>';
Attention to the use of single quotes (php values being echoed) and double quotes (pertaining to very string being echoed).
brasofilo thank you for your patiance but i am going to hang my self. i couldnt do this simple thing. i paste
<?php
$youtube = get_post_meta($post->ID, 'video_url', true);
echo '<object width="560" height="315"><param name="movie" value="' . $youtube . '?version=3&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="' . $youtube . '?version=3&hl=en_US" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object>';
?>
but nothing 🙁 look at the link:
http://www.1907.net/video-2/
you can see my media settings here:
media settings
easy man, don’t hang yourself…!
try this code and use only the Video ID as custom field
http://www.youtube.com/watch?v=mrpqiIOuf88
<?php if ( get_post_meta($post->ID, 'video_url', true) ) : ?>
<?php $youtube = get_post_meta($post->ID, 'video_url', true);
echo '<object width="560" height="315"><param name="movie" value="http://www.youtube.com/v/' . $youtube . '?version=3&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' . $youtube . '?version=3&hl=en_US" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object>';
?>
<?php endif; ?>
video id is tricky. becouse vimeo, dalymotion . they all have video id. if i use youtube video id. i have to open 2-3 more fields for other video sharing sites. and also telling the auhtors go find and crop the id is anoying i think.
but if video id is my final solution i have to stick with it
I donnow why oEmbed is not working for you…
Take a look at this article: http://www.makeuseof.com/tag/oembed-wordpress-easier-technology-explained/
Otherwise, there are plugin options for dealing with Video Shortcodes…
if i open a admin account to you could you look it up from there? is it possible?
sorry mate, that’s a matter to http://jobs.wordpress.net