what about this
you replace the output to just have the video id.
// delete youtube from output
str_replace("youtube","",$yourOutputShownOnYourSide);
// you will get something like "[ yu44JRTIxSQ]"
str_replace("[","",$yourOutputShownOnYourSide);
// you will get something like " yu44JRTIxSQ]"
str_replace("]","",$yourOutputShownOnYourSide);
// you will get something like " yu44JRTIxSQ"
trim($yourOutputShownOnYourSide);
// you will get something like "yu44JRTIxSQ"
than you can create a link to that video or embed the vid
for link:
// echo link
echo "http://www.youtube.com/watch?v=".$yourOutputShownOnYourSide;
// echo embed
echo "<iframe class=\"youtube-player\" type=\"text/html\" width=\"640\" height=\"385\" src=\"http://www.youtube.com/embed/".$yourOutputShownOnYourSide."\" frameborder=\"0\">
</iframe>";
(not tested the code)
Thread Starter
lizzmo
(@lizzmo)
Thanks very much, I simplified it a bit, but you definitely put me in the right direction!
Changed to vimeo because the youtube video wouldn’t follow its z-index, even when I added wmode.
Heres what I used in the end:
<?php if (get_post_meta($post->ID, 'VIDEO', true)) {
echo "<iframe src=\"http://player.vimeo.com/video/".$video."?byline=0&portrait=0&color=0096db\" width=\"466\" height=\"262\" frameborder=\"0\" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>";
} else { }; ?>
So all I have to put in the custom field is the video id number, no need for a shortcode or str_replace.
Thanks again!
that looks fine 🙂 good job