Title: Query_posts without a custom field
Last modified: August 20, 2016

---

# Query_posts without a custom field

 *  [djhsecondnature](https://wordpress.org/support/users/djhsecondnature/)
 * (@djhsecondnature)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/query_posts-without-a-custom-field/)
 * I’m trying to select posts without a particular custom field. Some posts will
   have it, some won’t, I want to grab just the ones that do not have it.
 * Something like this:
 *     ```
       $args = array(
           'meta_query' => array(
               array(
                   'key' => '$customfield',
                   'value' => NULL,
                   'compare' => '='
                   )
                )
             );
       ```
   
 * But not that, as that doesn’t work.
 * Anyone have any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [djhsecondnature](https://wordpress.org/support/users/djhsecondnature/)
 * (@djhsecondnature)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/query_posts-without-a-custom-field/#post-2309391)
 * *bump*
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/query_posts-without-a-custom-field/#post-2309392)
 * `'meta_value' => '_wp_zero_value'`?
    [http://codex.wordpress.org/Function_Reference/WP_Query#Custom_Field_Parameters](http://codex.wordpress.org/Function_Reference/WP_Query#Custom_Field_Parameters)

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Query_posts without a custom field’ is closed to new replies.

## Tags

 * [meta_key](https://wordpress.org/support/topic-tag/meta_key/)
 * [meta_query](https://wordpress.org/support/topic-tag/meta_query/)
 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [14 years, 7 months ago](https://wordpress.org/support/topic/query_posts-without-a-custom-field/#post-2309392)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
