Skip to content

Instantly share code, notes, and snippets.

@ebuildy
Created December 22, 2017 16:06
Show Gist options
  • Save ebuildy/0794a07652878c28d75fd449c20a3e86 to your computer and use it in GitHub Desktop.
Save ebuildy/0794a07652878c28d75fd449c20a3e86 to your computer and use it in GitHub Desktop.
Wordpress wp-ml plugin: pivot term by languages
SELECT wp_icl_translations.trid,
group_concat(case when wp_icl_translations.language_code = "sp" then wp_terms.name end) as title,
group_concat(case when wp_icl_translations.language_code = "sp" then wp_term_taxonomy.term_taxonomy_id end) as sp,
group_concat(case when wp_icl_translations.language_code = "en" then wp_term_taxonomy.term_taxonomy_id end) as en
FROM wp_terms
INNER JOIN wp_term_taxonomy ON wp_term_taxonomy.term_id = wp_terms.term_id
INNER JOIN wp_icl_translations ON wp_icl_translations.element_id = wp_term_taxonomy.term_taxonomy_id AND wp_icl_translations.element_type = "tax_event-categories"
WHERE wp_term_taxonomy.taxonomy = "event-categories" AND wp_term_taxonomy.parent = 0
GROUP BY wp_icl_translations.trid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment