Skip to content

Instantly share code, notes, and snippets.

@pablo-sg-pacheco
Created December 14, 2017 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pablo-sg-pacheco/41e614a4da27f051bd953ca18662eba6 to your computer and use it in GitHub Desktop.
Save pablo-sg-pacheco/41e614a4da27f051bd953ca18662eba6 to your computer and use it in GitHub Desktop.
Get WooCommerce product type
SELECT p.ID, p.post_title, t.name AS product_type
FROM wp_posts AS p
JOIN wp_term_relationships AS tr ON tr.object_id = p.id
JOIN wp_term_taxonomy AS tt ON tr.term_taxonomy_id=tt.term_taxonomy_id
JOIN wp_terms AS t ON t.term_id = tt.term_id
WHERE p.id = 111 AND tt.taxonomy = 'product_type'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment