How do I remove a taxonomy from Wordpress?

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

    I suggest you don't mess with the actual global. Its safer to simply deregister the taxonomy from the post type: register_taxonomy is used for both creation and modification.

    function ev_unregister_taxonomy(){
        register_taxonomy('post_tag', array());
    }
    add_action('init', 'ev_unregister_taxonomy');
    

    To remove the sidebar menu entry:

    // Remove menu
    function remove_menus(){
        remove_menu_page('edit-tags.php?taxonomy=post_tag'); // Post tags
    }
    
    add_action( 'admin_menu', 'remove_menus' );
    

提交回复
热议问题