Skip to content

Instantly share code, notes, and snippets.

@bookchiq
Created May 18, 2020 17:47
Show Gist options
  • Select an option

  • Save bookchiq/292d9ccfdcc7ab4d153022289ce329a9 to your computer and use it in GitHub Desktop.

Select an option

Save bookchiq/292d9ccfdcc7ab4d153022289ce329a9 to your computer and use it in GitHub Desktop.
Find WordPress posts that are missing a specific custom field/postmeta
SELECT *
FROM wp_posts
WHERE
post_type = "ycd_individual" AND
post_status = "publish" AND
ID NOT IN (
SELECT wp.ID
FROM wp_posts wp
LEFT JOIN wp_postmeta pm ON wp.ID = pm.post_id
WHERE
pm.meta_key = "yoko_directory_email_address" AND
pm.meta_value != "" AND
wp.post_type = "ycd_individual" AND
wp.post_status = "publish"
)
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment