Is there any way to see if a post exists by a meta value?
For instance, lets say I want to see if another post has a unique meta value of “pictureID”, and if so do something else.
Is there a way I could write that clause in php?
Thank you
Advertisement
Answer
if you dont know the post id then
you can use custom wordpress query to check post meta according to key like
global $wpdb; $wpdb->get_results( "select * from $wpdb->postmeta where meta_key = 'pictureID' " );
And then you can get all results with post id and then get that post data.
Hope this helps 😉