Title: WP_Query returning true when no posts
Last modified: August 22, 2016

---

# WP_Query returning true when no posts

 *  [M.Danz](https://wordpress.org/support/users/mdanz-1/)
 * (@mdanz-1)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/wp_query-returning-true-when-no-posts/)
 * I have the custom post type `cv` with no entries but WP_Query keeps returning
   i have entries?
 *     ```
       $query = new WP_Query(array('post_type' => 'cv','post_author' => $user_id, 'post_title' => $page_user));
   
       if ( have_posts() ) :
            while ( have_posts() ) : the_post();
               $post_id = $post->ID;
       echo $post_id;
            endwhile; 
   
            $exists = 1;
   
       else :
            $exists = 0;
       endif;
       ```
   
 * When i echo `$post_id` i get 2896 but i have made sure to delete all posts for
   this custom post type with a query.
 * How do i solve this?; WP_Query should return false.

Viewing 1 replies (of 1 total)

 *  Moderator [Jose Castaneda](https://wordpress.org/support/users/jcastaneda/)
 * (@jcastaneda)
 * THEME COFFEE MONKEY
 * [11 years, 4 months ago](https://wordpress.org/support/topic/wp_query-returning-true-when-no-posts/#post-5597493)
 * I think it could be because you aren’t passing/setting the query.
 * It should be:
 *     ```
       if ( $query->have_posts() ):
           while( $query->have_posts() ): $query->the_post();
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘WP_Query returning true when no posts’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Jose Castaneda](https://wordpress.org/support/users/jcastaneda/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/wp_query-returning-true-when-no-posts/#post-5597493)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
