Check the database for a postmeta field

You don’t need to set a new WP_Query since you are looping through the data of the octopus. I would do the following in your case: Create a function that checks if there is a post with an octopus_id given function post_with_octopus_id_exists( $octopus_id ){ //If for some reason the $octopus_id given is empty return false … Read more

Get unique post by meta value using wp_query

You can simply limit the query to return only one result. To achieve this, use the field posts_per_page in your query arguments. Check the documentation for more info on this. $args = [ ‘cat’ => ’44’, ‘posts_per_page’ => ’16’, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘meta_query’ => [ ‘metavalue1’ => [ ‘key’ => ‘Meta_value’, ‘value’ … Read more