Skip to content

Instantly share code, notes, and snippets.

@ajskelton
Created July 26, 2021 22:23
Show Gist options
  • Save ajskelton/915675de94d914bbadd9bcef965c3cbc to your computer and use it in GitHub Desktop.
Save ajskelton/915675de94d914bbadd9bcef965c3cbc to your computer and use it in GitHub Desktop.
WordPress SQL Query for finding posts that have a specific acf value
SELECT * FROM wp_posts
LEFT JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id
WHERE wp_posts.post_status = 'publish'
AND wp_postmeta.meta_value = '%ACF_FIELD_VALUE%'
ORDER BY wp_posts.ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment