Skip to content

Instantly share code, notes, and snippets.

@titodevera
Created July 10, 2017 21:45
Show Gist options
  • Save titodevera/9b7bbf555c2debe22eea899b93dbe3c6 to your computer and use it in GitHub Desktop.
Save titodevera/9b7bbf555c2debe22eea899b93dbe3c6 to your computer and use it in GitHub Desktop.
Retrieve the brands for a product using SQL
SELECT t.*, tt.* FROM wp_terms AS t
INNER JOIN wp_term_taxonomy AS tt ON (tt.term_id = t.term_id)
INNER JOIN wp_term_relationships AS tr ON (tr.term_taxonomy_id = tt.term_taxonomy_id)
WHERE tt.taxonomy IN ('pwb-brand') AND tr.object_id IN (¡¡PRODUCT ID GOES HERE!!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment