默认情况下 ,自定义文章类型没有分类和标签属性,需要通过 register_taxonomy_for_object_type 手动注册文章分类和标签,可以通过在 functions.php 或插件中添加如下代码:

 

add_action( 'init', 'sk_add_category_taxonomy_to_events' );
/**
 * Link `e4gf_events` CPT to categories and tags taxonomies
 */
function sk_add_category_taxonomy_to_events() {
    register_taxonomy_for_object_type( 'category', 'e4gf_events' );
    register_taxonomy_for_object_type( 'post_tag', 'e4gf_events' );
}

e4gf_events 为文章类型

 

Wordpress 自定义文章类型添加 Categoried、Tags

 

效果如下:

 Wordpress 自定义文章类型添加 Categoried、Tags

 

 

资料来源链接:

https://sridharkatakam.com/adding-categories-support-to-a-custom-post-type-in-wordpress/

相关文章:

  • 2018-07-02
  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
  • 2021-07-07
  • 2022-02-15
  • 2022-12-23
  • 2021-11-13
猜你喜欢
  • 2021-10-26
  • 2022-12-23
  • 2021-10-18
  • 2022-12-23
  • 2022-12-23
  • 2021-08-24
  • 2022-12-23
相关资源
相似解决方案