Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove a taxonomy from Wordpress?

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?

Thanks.

like image 389
Evan Avatar asked Nov 22 '10 20:11

Evan


People also ask

How do I delete taxonomies?

You can find this by visiting the Taxonomies screen and editing a taxonomy. You can not delete Tags and Categories because they are core features of WordPress. You also can not delete taxonomies from a third party plugin such as WooCommerce. For Tags and Categories, you can only click “Deactivate Taxonomy”.

How do I register a taxonomy for custom post type?

' So make sure you have a custom post type created before you begin creating your taxonomies. Next, go to CPT UI » Add/Edit Taxonomies menu item in the WordPress admin area to create your first taxonomy. On this screen, you will need to do the following: Create your taxonomy slug (this will go in your URL)


2 Answers

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' ); 
like image 119
Evan Avatar answered Sep 19 '22 16:09

Evan


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' ); } 
like image 31
cameronjonesweb Avatar answered Sep 22 '22 16:09

cameronjonesweb