Get Post ID by Content

WordPress has a handy function called post_exists() which allows you to find an existing post by its title, content, and/or date. It returns the post ID on success or 0 otherwise.

In your case, you can use $post_id = post_exists( '', '{"member_id":33}' ) to find the post you’re looking for.

Note: That function doesn’t check the post type so you’d need to do that separately or roll your own function if it’s necessary. I doubt it though that you have other posts with the same content 🙂

Leave a Comment