0

I have a custom loop that should be getting 6 posts but it's only returning 4. There are 6 in the category

 $args = array( 'category_name' => 'audio', 'posts_per_page' => -1 ); 
 $audio = new WP_Query( $args ); 
 if( $audio->have_posts()): 

 <?php while ( $audio->have_posts()) : $audio->the_post();
  $audioUrl = get_children( array('post_parent' => $post->ID, 'post_status' => 'published', 'post_type' => 'attachment', 'post_mime_type' => 'audio' ) ); ?>

 <?php foreach ( $audioUrl as $attachment_id => $attachment ) : ?>
 <li><a href="#" data-src="<?php echo wp_get_attachment_url( $attachment_id, 'full' ); ?>" class="tracks" title="<?php the_title(); ?>"><?php the_post_thumbnail(); ?><?php the_title(); ?></a></li>
 <?php endforeach; ?>

The above code does exactly what I need which is to get the url of the attached audio file but it won't return all 6.

  • are all the 6 published ? and public, not private ? – mmm Jun 28 '15 at 21:40
  • all are public, all are published, all have audio files attached. If I remove the foreach that gets the urls, then all 6 show up. – Jamie Jun 28 '15 at 22:46
  • It could be that you ain't got debugging turned on. – kaiser Jun 28 '15 at 23:03
  • I do have debugging turned on. I am not receiving any error messages – Jamie Jun 28 '15 at 23:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.