Assign / update custom field value for all posts (How can I assign only to posts without custom field value?)
You can use meta_query parameter (and Query all posts where a meta key does not exist) to limit the query to only posts that have or don’t have a certain meta value. $query = new WP_Query(array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘your_meta_key’, ‘compare’ => ‘NOT … Read more