今天尝试给自定义文章类型添加分类时发现,CPT默认的类别调用的是文章的类别,那么,有没有办法实现给自定义的文章类型添加独立的分类呢?
通过谷歌搜索,我终于找到了问题的解决方案,这个方法是老外分享的,那么下面我就把该教程的原文贴上,有时间了再翻译。
下面这个是YouTube视频的链接,国内可能播放不了
https://youtu.be/_trxOg7aoq8
In order to start working with taxonomies, you need to register a custom post type first. Below is the reference that you can copy/paste. Make sure to tweak it according to your liking! If you need to create multiple custom post types, I highly suggest to declare a function to organize them.
Things To Know For WordPress Taxonomy
Please keep in mind that you need to change your taxonomy, please replace the “press_categories” and “press_tags” to your preferred name. The second array should also match on your custom post type so ‘press’ word should be changed. Kindly check my video for further instruction.
To add more arrays on your taxonomies, check our WordPress official documentation
WordPress Taxonomy Code For Categories
WordPress Taxonomy Code For Tags
如果想了解更多关于此教程的内容,可以查看下这篇文章或者这篇文章。