How do I remove a taxonomy from Wordpress?

前端 未结 7 773
一个人的身影
一个人的身影 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:48

    Where it says 'taxonomy_to_remove' is where you'll enter the taxonomy you want to remove. For instance you can replace it with the existing, post_tag or category.

    add_action( 'init', 'unregister_taxonomy');
    function unregister_taxonomy(){
        global $wp_taxonomies;
        $taxonomy = 'taxonomy_to_remove';
        if ( taxonomy_exists( $taxonomy))
            unset( $wp_taxonomies[$taxonomy]);
    }
    

提交回复
热议问题