register_taxonomy_for_object_type()
register_taxonomy_for_object_type( string $taxonomy, string $object_type )
将已注册的分类添加到对象类型。
Add an already registered taxonomy to an object type.
参数(Parameters)
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
$taxonomy | (string) | 必需 | 分类对象的名称。 |
$object_type | (string) | 必需 | 对象类型的名称。 |
返回(Return)
(bool)如果成功则为True,否则为false。
源码(Source)
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
3.0.0 | wp-includes/taxonomy.php:612 | 1 function | 3 |
笔记(Notes)
例子
不要忘记使用init钩子来运行这个函数。如果没有,您想要引用的分类法和/或CPT可能还没有创建。
register_taxonomy_for_object_type() 为WP2原创文章,链接:https://www.wp2.cn/functions/register_taxonomy_for_object_type/