1

so as the questions states, what im trying to accomplish is to fetch only the posts that do not have a featured image set. i tried looking through the docs and i noticed you can use the - symbol to exclude something from your argument, but that isn't working for me. Is there something else i can do in my query args to achieve this? thanks for your help!

$mediaargs = array(
        'post_type' => 'media',
        'posts_per_page' => 1,
        'paged' => $paged,
        'order' => 'DESC',
        'orderby' => 'modified',
        'meta_key' => '-_thumbnail_id',
    );
2
$mediaargs = array(
        'post_type' => 'media',
        'posts_per_page' => 1,
        'paged' => $paged,
        'order' => 'DESC',
        'orderby' => 'modified',
        'meta_query' => array(
            array(
                'key' => '_thumbnail_id',
                '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.