• 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

    (@jcastaneda)

    THEME COFFEE MONKEY

    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.