Skip to content

Instantly share code, notes, and snippets.

@adamdoe
Created Mar 4, 2019
Embed
What would you like to do?
WordPress SQL for post, category, user data
SELECT
p.ID,
p.post_author,
p.post_date,
u.display_name,
p.post_title,
p.post_content,
t.name
FROM wp_posts as p
INNER JOIN wp_postmeta as pm ON (p.ID = pm.post_id)
INNER JOIN wp_term_relationships as tr ON (tr.object_id = p.ID)
INNER JOIN wp_term_taxonomy as tt ON (tt.term_taxonomy_id = tr.term_taxonomy_id)
INNER JOIN wp_terms as t ON (t.term_id = tr.term_taxonomy_id)
INNER JOIN wp_users as u ON (u.ID = p.post_author)
WHERE p.post_type = 'post'
GROUP BY p.ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment