How do I remove a taxonomy from Wordpress? How do I remove a taxonomy from Wordpress? wordpress wordpress

How do I remove a taxonomy from Wordpress?


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 menufunction remove_menus(){    remove_menu_page('edit-tags.php?taxonomy=post_tag'); // Post tags}add_action( 'admin_menu', 'remove_menus' );


Perhaps a more technically correct method would be to use unregister_taxonomy_for_object_type

add_action( 'init', 'unregister_tags' );function unregister_tags() {    unregister_taxonomy_for_object_type( 'post_tag', 'post' );}


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]);}