How do I remove a taxonomy from Wordpress?

前端 未结 7 629
一个人的身影
一个人的身影 2021-02-01 17:10

I\'m creating different custom post types and taxonomies and I want to remove the \'Post Tags\' taxonomy from the default \'Posts\' post type. How do I go about doing this?

7条回答
  •  囚心锁ツ
    2021-02-01 17:45

    Total unregister and remove (minimal PHP version 5.4!)

    add_action('init', function(){
            global $wp_taxonomies;
            unregister_taxonomy_for_object_type( 'category', 'post' );
            unregister_taxonomy_for_object_type( 'post_tag', 'post' );
            if ( taxonomy_exists( 'category'))
                unset( $wp_taxonomies['category']);
            if ( taxonomy_exists( 'post_tag'))
                unset( $wp_taxonomies['post_tag']);
            unregister_taxonomy('category');
            unregister_taxonomy('post_tag');
        });
    

提交回复
热议问题