Attach custom field thumbnail using php
-
Hi I am trying to create a video gallery that opens in fancybox. I am almost there I inserted the youtube link in an link tag and it works. Now I just need to attach $video_thumbnail (the thumbnail) to the img tag src. I am somewhat new to php ..Here is my code:
<ul class="filterable-grid clearfix"> <?php /* Loop the stuff from the videos post type */ $args = array( 'order'=> 'ASC', 'orderby' => 'title', 'post_type' => 'television', 'posts_per_page' => -1 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post();?> <li> <?php /* Set variables and create if stament */ $video_thumbnail = get_post_meta($post->ID, 'Video Thumbnail', single); $videosite = get_post_meta($post->ID, 'Video Site', single); $videoid = get_post_meta($post->ID, "Video ID", single); if ($videosite == vimeo) { echo '<iframe src="https://player.vimeo.com/video/'.$videoid.'" width="300" height="200" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'; } else if ($videosite == youtube) { echo '<a class="fancybox" title="" href="https://www.youtube.com/watch?v='.$videoid.'?fs=1&autoplay=1"><img src="'<?php echo $video_thumbnail ?>'" /></a>'; } else { echo 'Please Select Video Site Via the CMS'; } ?> </li> <?php endwhile;?> </ul>
Right now I am just focusing on the youtube code. Every video post has a custom field thumbnail called $video_thumbnail. Thanks for your help!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Attach custom field thumbnail using php’ is closed to new replies.