I have tow WP_Query loops running on a page. The first query displays the sticky posts and the second query is set according to meta_value. The trouble I am having is when there is no-sticky posts, the query seems to display all the available posts, which is definitely no what I need. I need it to display nothing found, if there are no posts found according to query.
$com_soon = array( 'post_type' => 'post', 'post__in' => get_option( 'sticky_posts'), 'numberposts' => -1, 'cat' => 2 ); $cs_profiles = new WP_Query($com_soon); if ($cs_profiles->have_posts()) : while ($cs_profiles->have_posts()) : $cs_profiles->the_post();?> //the loop here endwhile; else: echo 'NOTHING FOUND'; endif;
I guess this is some wp fallback mechanism. Is there any way I could avoid this because the if-have-posts doesnot seem to work here.