I have videos set up as a custom post type and music, commercial, promo set up as categories within this post type:
I have a function that displays a custom meta box on the videos post type pages in the wordpress back end. The user is able to enter the ID of a youtube video or the ID of a vimeo video - wordpress then displays the video for the ID on custom post type page. When a user adds a new post to the videos custom post type and assigns it to any of the categories I specify I want wordpress to display the different videos. The code I have at the moment is not doing what I want it to do because it is displaying the same video on each post even though an ID hasnt been specified on some of them. For example on the music post page I have assigned it the category music and put a vimeo video ID which is displayed on the front end but then the same video is displayed for promo and commercial and I dont want that to happen. The loop I have running this is (in single-videos.php):
<?php
$args = array( 'post_type' => 'videos', 'posts_per_page' => 20, 'orderby' => 'date', 'order' => 'ASC' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
//$args = array( 'post_type' => 'videos', 'posts_per_page' => 20, 'orderby' => 'date', 'order' => 'ASC' );
$ytubeID = get_post_meta($post->ID, '_youtubeID', true);
$vimID = get_post_meta($post->ID, '_vimeoID', true);
if ($ytubeID || $vimID){
if ($ytubeID){
echo '<iframe title="YouTube video player" class="youtube-player" type="text/html" src="http://www.youtube.com/embed/'.$ytubeID.'" allowfullscreen="true" frameborder="0" width="640" height="390">';
echo '</iframe>';
} elseif ($vimID){
echo '<br />';
echo '<iframe src="http://player.vimeo.com/video/'.$vimID.'" width="640" height="390" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
}//end if yutbeID or vimIDthe_excerpt(); //excerpt added for information
}
endwhile;
wp_reset_query();
?>