简体   繁体   English

WP术语ID(按分类)

[英]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.

相关问题 WP查询:排除自定义分类法的所有术语 - WP Query: Exclude ALL terms of a custom taxonomy 在WP_Query中包括分类术语 - Include Taxonomy Terms in WP_Query 使用wp_set_object_terms添加自定义分类术语 - Using wp_set_object_terms to add custom taxonomy terms 通过 WP_Query 中的分类术语和自定义字段过滤 WooCommerce 产品 - Filter WooCommerce products by taxonomy terms and custom fields in a WP_Query Wordpress wp_set_object_terms不适用于自定义分类法 - Wordpress wp_set_object_terms is not working for custom taxonomy wp_set_object_terms无法使用自定义分类法和cpt - wp_set_object_terms not working with custom taxonomy and cpt Wordpress:WP_Query 循环中带有分类术语 ID 的输出列表 - Wordpress: Output list with taxonomy term IDs in WP_Query loop 如何在WordPress中左联接wp_terms,wp_term_relationships,wp_term_taxonomy和wp_termmeta表? - How to LEFT JOIN the wp_terms, wp_term_relationships, wp_term_taxonomy and wp_termmeta tables in WordPress? 如何将drupal中的分类术语与另一个数据库中的类别ID相关联? - How can I relate taxonomy terms in drupal with category ids in another db? wp_axax_在类方法中调用的WordPress get_terms(),返回“无效分类法” - WordPress get_terms() called by wp_axax_ inside a class method, returns “Invalid taxonomy”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM