Created
November 8, 2013 17:38
-
-
Save pdewouters/7374687 to your computer and use it in GitHub Desktop.
Returns the parent and child term slugs separated by a slash `parent-slug/child-slug`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT CONCAT(parents.parent_slug, '/', children.slug) AS slug | |
| FROM | |
| ( | |
| SELECT distinct t.term_id ,t.slug AS parent_slug | |
| FROM wp_term_taxonomy AS tt | |
| INNER JOIN wp_terms AS t | |
| ON tt.parent = t.term_id | |
| ) parents | |
| INNER JOIN | |
| ( | |
| SELECT t.slug, tt.term_id, tt.parent | |
| FROM wp_term_taxonomy AS tt | |
| INNER JOIN wp_terms AS t | |
| ON tt.term_id = t.term_id | |
| ) children | |
| ON parents.term_id = children.parent | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment