Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

The title says it all. At the moment in my custom taxonomies I'm getting the terms using the term id and taxonomy name.

Thought this question would've been asked before but can't find it anywhere! So just thought I'd ask and see if anyone has any answers.

share|improve this question

2 Answers 2

up vote 9 down vote accepted

If you take a look into the Wordpress documentation you will find Wordpress Taxonomies

  • term_id is the ID of a term in the terms table
  • term_taxonomy_id is a unique ID for the term + taxonomy pair.
share|improve this answer
so manipulating and grabbing terms based only on the term_id wouldn't cause duplicates then? – Coombesy Jan 2 '12 at 18:51
actually just answered that last question. Had a look at the wp_terms table and yep using the term_id only is safe. Thanks for your reply @Juan – Coombesy Jan 2 '12 at 18:55

A term is not a category or tag on its own. It must be given context via the term_taxonomy table.

The term_taxonomy table places a term within a taxonomy. This is what makes a term a category, a tag or part of a custom taxonomy (or in a combination of taxonomies).

term_id is the ID of a term in the terms table.

term_taxonomy_id is a unique ID for the term+taxonomy pair.

The term_id is always unique just like the term_taxonomy_id. Both have an Auto Increment in the table structure.

The table wp_term_taxonomy makes sure for example that a category is created, so wordpress can interfere with it e.g Woocommerce uses: product_tag, product_type, product_cat, all of them are the so called custom taxonomies. This table also binds the parent/children structure. With it's column parent.

The final table, term_relationships, relates objects such as posts or links to a term_taxonomy_id from the term_taxonomy table.

If we pick Woocommerce again as an example, this table links post type products to their taxonomy product_cat, which contains a namy e.g Computers which is of course retrieved from the table wp_terms. This table contains the term_id, name, slug and term_group. (term_group I personally have never used)

Hopefully the above makes things a bit more clear about the differences and how Wordpress uses these tables.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.