Site icon Hip-Hop Website Design and Development

Get posts for which a custom field is not present, with get_posts

I’d like to get all posts for which the custom field hidden is NOT present. This does not work:

$postsForSitemap = get_posts(array(
    'numberposts' => -1, 
    'orderby' => 'modified', 
    'post_type' => array('post', 'page'), 
    'order' => 'DESC', 
    'meta_key' => 'hidden', 
    'meta_compare' => '!=')
);

because meta_compare is about the meta_value, not the key.

I haven’t found in the documentation https://developer.wordpress.org/reference/classes/wp_query/#custom-field-post-meta-parameters how to get all posts that don’t have a specific custom field.

How to do this?