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
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
You must be logged in to post a comment.
if you dont know the post id then
you can use custom wordpress query to check post meta according to key like
And then you can get all results with post id and then get that post data.
Hope this helps 😉
You can use a standard
WP_Query
to return posts bymeta_key
using themeta_query
argument andEXISTS
compare type.If you want to quickly grab a random post_id that has this meta_key set you can go to the database directly (bypassing caching, etc).
first try to get meta value for post get_post_meta()