• Resolved lizzmo

    (@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: https://design-science.org.uk/the-sum-of-all-paths/

    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
    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 "https://www.youtube.com/watch?v=".$yourOutputShownOnYourSide;
    
    // echo embed
    echo "<iframe class=\"youtube-player\" type=\"text/html\" width=\"640\" height=\"385\" src=\"https://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=\"https://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

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