Query Posts Where Custom Field is NULL

To query posts where a specific custom field is null, use the snippet below:

$args = array(
    'posts_per_page' => -1,
    'post_type' => 'my_post_type', // change
    'post_status' => 'publish',
    'order' => 'DESC',
    'orderby' => 'date',
    'meta_query' => array(
        'relation' => 'OR',
        array(
            'key' => 'my_custom_field', // change
            'compare' => 'NOT EXISTS'
        )
    )
);

// Build Query
$query = new WP_Query($args);