I’m looking for a way to check how many posts are returned by a specific loop. So if I have a loop like this..
<?php
$featured_post_id = get_the_ID();
global $post;
$args = array('cat' => '9', 'posts_per_page' => 5, 'post__not_in' => array($featured_post_id) );
$my_query = new WP_Query($args);
if ( $my_query->have_posts() ) : while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
And if this loop returns less than 5 posts then I want to show something. In my situation I’d be showing another loop to add more results.
Try this:
Good luck! Hope that helps.