I want to get all the posts for which the post_name(slug) is not set/empty as well as a meta_key does not exist.
$args = array (
'post_type' => 'books',
'name' => '',
'post_status' => array('publish, draft'),
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'book_isbn_id',
'value' => 'dummy',
'compare' => 'NOT EXISTS',
'type' => 'NUMERIC',
),
),
);
$query = new WP_Query( $args );
echo $query->request;
It seems that 'name' = ''
or 'name' = ' '
is completely ignored from what I see from echo $query->request
.
Am I doing anything wrong?
meta_query
to check whether it gives you any result or not. Then you can add themeta_query
to further filter out the result. In themeta_query
, you have mentioned a string value but thetype
isNUMERIC
. Is it correct?