重新使用自定义帖子类型的默认类别/标签分类法?
在我的 WordPress 主题的 functions.php
中,我创建了一个名为 foobar
的自定义帖子类型。
是否可以重新使用 foobar 帖子的默认
类别和标签?或者我是否必须创建两种分类法:
- 一种用于类别,
- 另一种用于标签
才能实现此目的?
编辑:我想我已经通过在创建自定义帖子类型的函数中使用此代码解决了这个问题:
register_taxonomy_for_object_type('category', 'foobar');
register_taxonomy_for_object_type('post_tag', 'foobar');
In my wordpress theme's functions.php
, I've created a custom post type called foobar
.
Is it possible to re-use the default
categories and tags for foobar posts? Or do I have to create two taxonomies:
- one for categories
- the other for tags
to achieve this?
EDIT: I think I've solved this by using this code within the function that creates the custom post type:
register_taxonomy_for_object_type('category', 'foobar');
register_taxonomy_for_object_type('post_tag', 'foobar');
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以一石二鸟,并在注册帖子类型taxonomies键>:
You can kill two birds with one stone and use the
taxonomies
key when registering the post type: