admin管理员组

文章数量:1287818

I can't find the answer for this question on either Wordpress or here, nor via Google searches, so I'm throwing this out to the community.

If you have two taxonomies, and you add 1 term to each taxonomy, will the first term added in taxonomy_1 have a term ID of 1 and the second term added to taxonomy_2 have a term ID of 2?

I can't find the answer for this question on either Wordpress or here, nor via Google searches, so I'm throwing this out to the community.

If you have two taxonomies, and you add 1 term to each taxonomy, will the first term added in taxonomy_1 have a term ID of 1 and the second term added to taxonomy_2 have a term ID of 2?

Share Improve this question asked Jun 4, 2014 at 6:29 AshkasAshkas 1771 gold badge2 silver badges8 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 2

The short answer is no. If you have a look at terms, taxonomies and categories, all of them is stores in the database in the wp_terms table.

Every one of these are assigned a numerical value that is unique to that term/category/taxonomy. This don't just apply to "objects" added to wp_terms, but to anything added to a specific table in the db. So nothing added to a specific table will ever have the same ID

These ID's are assigned according to the "object's" place in the specific table, in numerical order. So if the last item in that specific table is number 16, the next item that is added will be number 17, hence ID 17 will be assigned to that "object". The next "object" added will then automatically be ID 18 and so forth

So, to conclude, ID's are assigned to their place in a table, and not according to their relation to another "object"

In recent versions of WP you are going to have unique term IDs. Evidence of this is the fact that the methods get_terms and get_term don't require you to pass a taxonomy name. If terms Ids were not unique across taxonomies then passing a taxonomy name would be necessary.

As a side note, there used to be the concept of shared terms but not anymore: https://make.wordpress/core/2015/06/09/eliminating-shared-taxonomy-terms-in-wordpress-4-3/

本文标签: Are term IDs unique even between multiple custom taxonomies