Skip to content

Instantly share code, notes, and snippets.

@nessthehero
Created May 18, 2018 11:07
Show Gist options
  • Save nessthehero/4ba39b620b502903a169e238a7bce41b to your computer and use it in GitHub Desktop.
Save nessthehero/4ba39b620b502903a169e238a7bce41b to your computer and use it in GitHub Desktop.
WordPress - Find posts without meta key
SELECT * FROM wp_posts as posts
WHERE posts.post_type = 'post'
AND NOT EXISTS (
SELECT * FROM `wp_postmeta`
WHERE `wp_postmeta`.`meta_key` = "your_meta_key"
AND `wp_postmeta`.`post_id`=posts.ID
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment