I am trying to get a custom loop to work and I can not see why it is failing.
$args = array( 'category_name' => 'audio', 'posts_per_page' => 6 );
$sound = new WP_Query( $args );
if( $sound->have_posts()):
while ( $sound->have_posts()) : $sound->the_post();
$file = get_attached_media('audio');
foreach( $file as $data) { ?>
<li><a href="#" data-src="<?php echo $data->guid; ?>" class="tracks" title="<?php the_title(); ?>"><?php the_post_thumbnail(); ?><?php the_title(); ?></a></li>
<?php } ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
Right now there is one post in the category. I had 6 but only 5 showed up on the page. So I deleted them all and started over. I made one post. Nothing shows. When I do a var dump of the $file variable, I get this
array(0){
}
shouldn't there be a "post" object there? is my loop messed up?