Skip to content

Instantly share code, notes, and snippets.

@ssatz
Created January 14, 2019 06:17
Show Gist options
  • Save ssatz/829548b271c4e865393797841f2a0a2a to your computer and use it in GitHub Desktop.
Save ssatz/829548b271c4e865393797841f2a0a2a to your computer and use it in GitHub Desktop.
Wordpress Get POST With Terms(with Category)
SELECT * FROM wp_posts LEFT JOIN wp_term_relationships
ON (wp_posts.ID = wp_term_relationships.object_id)
LEFT JOIN wp_term_taxonomy
ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id)
LEFT JOIN wp_terms
ON (wp_term_relationships.term_taxonomy_id = wp_terms.term_id)
WHERE wp_posts.post_type = 'post'
AND wp_term_taxonomy.taxonomy = 'category'
ORDER BY
post_date DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment