0

I am trying to fetch custom post by meta key,But I am unable to get this . when I am trying to run query without meta value its showing blank. any help

 $args = array(
                                 'post_type'         => 'mad_property',
                                 'post_status'       => 'publish',
                                 'paged'             => '-1',
                                                       'meta_query'  => array(
        array(
            'key' => 'seasonaldiscountdesc',
            'value' =>'',
        'compare' => '='
        )
    )
                                                       );
1

You have to use NOT EXISTS. You will get all posts, which do not have meta field 'seasonaldiscountdesc'.

$args = array(
    'post_type'         => 'mad_property',
    'post_status'       => 'publish',
    'paged'             => '-1',
    'meta_query'  => array(
        'key' => 'seasonaldiscountdesc',
        'compare' => 'NOT EXISTS'
    )
);            

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.