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

You could use NOT EXISTS as the value for comparem, you could also check for empty value if thats relevant This code only checks if hidden meta does not exists $postsForSitemap = get_posts([ ‘numberposts’ => -1, ‘orderby’ => ‘modified’, ‘post_type’ => [‘post’, ‘page’], ‘order’ => ‘DESC’, ‘meta_key’ => ‘hidden’, ‘meta_compare’ => ‘NOT EXISTS’ ]; This … Read more

How To Fix WP Query Returns Results But Shouldn’t?

Couple of things to consider here: 1.) Try adding the meta query only if the value is present: $pairedThing = get_field(‘myThing’); $args = [ ‘posts_per_page’ => 2, ‘post_type’ => ‘thing’, ]; if ( ! empty( $pairedThing ) ) { $args[‘meta_key’] = ‘identifier’; $args[‘meta_value’] = $pairedThing; } 2.) Account for posts without the meta-key set: $pairedThing … Read more

list/consult Taxonomy only for the respective author/creator in dashbboard

The WP_Term_Query class doesn’t have a method named set, and calling $query->set() in my case resulted in a fatal/critical error saying “Call to undefined method WP_Term_Query::set()“. :/ But you can directly modify the query_vars property (i.e. $query->query_vars), like so, to set, unset or override any query variables like meta_query: // Use this: $query->query_vars[‘meta_query’] = $meta_query; … Read more

featured posts order

It sounds like you want to use the ‘sticky’ functionality as a replacement for a tag or a category. Why not just put all the posts you want in a ‘tab’ category, then call your query for that category. You can use orderby in fancy ways (such as by post_meta($tab = get_posts(‘category=tab&orderby=date’);