I need to loop only 1 of the latest post-type post in my sidebar, however, I only want to loop the latest one that has a meta box checked. I use the metabox option to give the post-type two different looks (videos or photos).
I want to loop the photo type only and the problem is that if a video version of that post-type is the newest one, then it blows out the older one and displays nothing. Is there a way to do this by effecting the query arguments or something?
Here is what I have so far:
<?php $args = array( 'post_type' => 'my_post_type', '', 'posts_per_page' => -1 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php if(get_post_meta($post->ID, 'my_post_type', true)) : ?>
<?php the_title(); ?>
<?php endif; ?>
<?php endwhile; ?>