[英]WP terms IDs by taxonomy
My question is next: it is possible that 2 different terms, from 2 different taxonomies, to have the same ID? 接下来的问题是:两个不同分类法中的两个不同术语可能具有相同的ID?
From my experience, it must not, but I want to be sure, because, I am developing a plugin which add to default post new taxonomies, and I am using next method of saving: when term is saved, I am creating a option like next: 根据我的经验,它一定不能,但是我想确定,因为,我正在开发一个插件,该插件会添加到默认的新分类法之后,并且我正在使用下一种保存方法:保存术语时,我正在创建一个类似下一个:
"prefix_taxonomy">$term->term_id;
No, they cannot. 不,他们不能。 The ID assigned to any object in a specific table in the DB is unique.
分配给数据库中特定表中任何对象的ID是唯一的。 The ID represent the object's place in the DB.
ID代表对象在数据库中的位置。 ID's cannot be set and is auto assigned according to the entry's place in the DB.
ID不能设置,并且会根据条目在数据库中的位置自动分配。
These ID's never change, except when an object is deleted from the db and later reassigned. 这些ID永远不会改变,除非从数据库中删除了一个对象,然后又重新分配了它。
Example, if the last term has a ID of 10, the next term will be assigned ID 11. If term ID 11 is deleted, and a new term is added, it will be assigned ID 12, and not ID 11. Empty ID's does not get reused. 例如,如果最后一个术语的ID为10,则将为下一个术语分配ID11。如果删除了术语ID 11,并添加了一个新术语,则将为其分配ID 12,而不是ID 11。不能重用。
It is therefore also not recommended to hard-code any ID's and they will differ from site to site 因此,也不建议您对任何ID进行硬编码,因为每个ID 都会有所不同
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.