Support » Plugins » Hacks » Using video shortcode in custom field

  • Resolved lizzmo


    I’ve looked through the forums and the general consensus seems to be that this code should work:

    <?php if (get_post_meta($post->ID, 'VIDEO', true)) {
    echo do_shortcode(get_post_meta($post->ID, 'VIDEO', true));
    } else { }; ?>

    But all that shows up is the shortcode as plain text. Help please!

    Heres a link to the page:

    The video should have been above the slideshow.

Viewing 3 replies - 1 through 3 (of 3 total)
  • what about this

    you replace the output to just have the video id.

    // delete youtube from output
    // you will get something like "[ yu44JRTIxSQ]"
    // you will get something like " yu44JRTIxSQ]"
    // you will get something like " yu44JRTIxSQ"
    // you will get something like "yu44JRTIxSQ"

    than you can create a link to that video or embed the vid
    for link:

    // echo link
    echo "".$yourOutputShownOnYourSide;
    // echo embed
    echo "<iframe class=\"youtube-player\" type=\"text/html\" width=\"640\" height=\"385\" src=\"".$yourOutputShownOnYourSide."\" frameborder=\"0\">

    (not tested the code)

    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=\"".$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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Using video shortcode in custom field’ is closed to new replies.