treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Open youtube video on Lightbox in WordPress

  • I am working on a WordPress theme which I want to add a Custom Fields for YouTube video, and this is what I got:

    How do I put a YouTube video with this?



    <?php if (get_post_meta($post->ID, 'youtube', true)) {
    $videourl = get_post_meta($post->ID, 'youtube', true);
    echo '<div class="zoom zoom_v"><span class="hovervideo"><a rel="lightbox" href="'.$videourl.'" title="'.get_the_title().'" class="youtube thumb thickbox mag">'; the_post_thumbnail(portfolio); echo '</a></span></div>';
    </pre>
  • i don't have experience using custom field. i am sure it is easy to create plugin for this, create shortcode to pass youtube id from editor to plugin, and return value with proper embed code, or in your problem, return a button/link/etc, trigger open lightbox on click.
  • let me know if you still having problem with this. will spent some time to create it. :D
  • I use FancyBox


    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script&gt;
    <script>
    !window.jQuery && document.write('<script src="jquery-1.4.3.min.js"><\/script>');
    </script>
    <script type="text/javascript" src="jquery.mousewheel-3.0.4.pack.js"></script>
    <script type="text/javascript" src="jquery.fancybox-1.3.4.pack.js"></script>

    $("#various3").fancybox({
    'width' : '75%',
    'height' : '75%',
    'autoScale' : false,
    'transitionIn' : 'none',
    'transitionOut' : 'none',
    'type' : 'iframe'
    });
  • Thanks mate, this one did the trick: http://iaian7.com/webcode/Mediabox/

    The good thing, I place only the web address, and it makes it a playable video lightbox. Very nice.