Skip to content

Instantly share code, notes, and snippets.

@hamidrezayazdani
Last active May 10, 2021 17:17
Show Gist options
  • Save hamidrezayazdani/b4ea6c9856e2bf8113690445e9e586cb to your computer and use it in GitHub Desktop.
Save hamidrezayazdani/b4ea6c9856e2bf8113690445e9e586cb to your computer and use it in GitHub Desktop.
# For posts categories
SELECT t.term_id AS id,
t.name AS 'Term Title',
t.slug AS 'Slug'
FROM wp_terms t
LEFT JOIN wp_term_taxonomy tt
ON t.term_id = tt.term_id
WHERE tt.taxonomy = 'category'
ORDER BY name;
# For posts tags
SELECT t.term_id AS id,
t.name AS 'Term Title',
t.slug AS 'Slug'
FROM wp_terms t
LEFT JOIN wp_term_taxonomy tt
ON t.term_id = tt.term_id
WHERE tt.taxonomy = 'post_tag'
ORDER BY name;
# For WooCommerce product categories
SELECT t.term_id AS id,
t.name AS 'Term Title',
t.slug AS 'Slug'
FROM wp_terms t
LEFT JOIN wp_term_taxonomy tt
ON t.term_id = tt.term_id
WHERE tt.taxonomy = 'product_cat'
ORDER BY name;
# For WooCommerce product tags
SELECT t.term_id AS id,
t.name AS 'Term Title',
t.slug AS 'Slug'
FROM wp_terms t
LEFT JOIN wp_term_taxonomy tt
ON t.term_id = tt.term_id
WHERE tt.taxonomy = 'product_tag'
ORDER BY name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment