title: Test If WP_Query Object Is Empty
body: <p>How can I test to see if a WP_Query object does not return any matches? I'd like to be able to do something like this is a template:</p>
  
  <pre><code>&lt;?php
      $my_query = new WP_Query(array('post_type' =&gt; 'biographies'))
      if( ***HOW DO I TEST $my_query HERE*** ) {
          //if $my_query finds anything loop through it here
      } else {
          //if $my_query does not find anything            
      }
  ?&gt;
  </code></pre>
  
  <h1>EDIT</h1>
  
  <p>Better example, I want to only display the h2 if the query finds anything:</p>
  
  <pre><code>&lt;?php
      $outside_leasing_query = new WP_Query(array( 'post_type' =&gt; 'resin_biographies', 'tax_query' =&gt; array(
          'relation' =&gt; 'AND',
          array( 'taxonomy' =&gt; 'resin_buildings', 'field' =&gt; 'slug', 'terms' =&gt; $page_slug ),
          array( 'taxonomy' =&gt; 'resin_leasing_companies', 'field' =&gt; 'slug', 'terms' =&gt; 'rubenstein-partners', 'operator' =&gt; 'NOT IN' )
      ) )); // resin_buildings taxonomy term slug must match page slug
  ?&gt;
  
  &lt;h2&gt;Outside Leasing Contacts&lt;/h2&gt;
  
  &lt;?php while ( $outside_leasing_query-&gt;have_posts() ) : $outside_leasing_query-&gt;the_post(); ?&gt;
  
      &lt;article &lt;?php post_class('group'); ?&gt;&gt;
          &lt;?php
          if( get_post_meta( $post-&gt;ID, '_biography_headshot', true ) != '' ) {
              echo '&lt;img class="contact-thumb" src="' . get_post_meta( $post-&gt;ID, '_biography_headshot', true ) . '" alt="'. get_the_title() .'" /&gt;';
          } else {
              echo '&lt;img class="contact-thumb-placeholder" src="' . get_bloginfo('template_url') . '/images/default_headshot.jpg" alt="'. get_the_title() . '" /&gt;';
          }
          ?&gt;
          &lt;div class="contact-info"&gt;
              &lt;hgroup&gt;
                  &lt;?php the_title( '&lt;h3&gt;', '&lt;/h3&gt;' ); ?&gt;
                  &lt;h4 class="contact-title"&gt;&lt;?php echo get_post_meta( $post-&gt;ID, '_biography_title', true ); ?&gt;&lt;/h4&gt;
              &lt;/hgroup&gt;
              &lt;div class="contact-address"&gt;&lt;?php echo wpautop( get_post_meta( $post-&gt;ID, '_biography_address', true ) ); ?&gt;&lt;/div&gt;
              &lt;div class="contact-tel"&gt;&lt;span&gt;T&lt;/span&gt; &lt;?php echo get_post_meta( $post-&gt;ID, '_biography_tel', true ); ?&gt;&lt;/div&gt;
              &lt;?php if( get_post_meta( $post-&gt;ID, '_biography_fax', true ) != '' ) { ?&gt;
                  &lt;div class="contact-fax"&gt;&lt;span&gt;F&lt;/span&gt; &lt;?php echo get_post_meta( $post-&gt;ID, '_biography_fax', true ); ?&gt;&lt;/div&gt;
              &lt;?php } ?&gt;
              &lt;div class="contact-email"&gt;&lt;a href="mailto:&lt;?php echo get_post_meta( $post-&gt;ID, '_biography_email', true ); ?&gt;"&gt;&lt;?php echo get_post_meta( $post-&gt;ID, '_biography_email', true ); ?&gt;&lt;/a&gt;&lt;/div&gt;
          &lt;/div&gt;
      &lt;/article&gt;
  
  &lt;?php endwhile; ?&gt;
  &lt;?php wp_reset_postdata(); ?&gt;
  </code></pre>