900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > Wordpress 自定义文章类型添加 Categoried Tags

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

时间:2021-10-08 06:16:32

相关推荐

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

默认情况下 ,自定义文章类型没有分类和标签属性,需要通过 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 为文章类型

效果如下:

资料来源链接:

/adding-categories-support-to-a-custom-post-type-in-wordpress/

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。