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.
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.
You must be logged in to post a comment.
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.
To remove the sidebar menu entry:
Perhaps a more technically correct method would be to use
unregister_taxonomy_for_object_type
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
orcategory
.Total unregister and remove (minimal PHP version 5.4!)
There is new function to remove taxonomy from WordPress.
Use unregister_taxonomy( string $taxonomy ) function
See details: https://developer.wordpress.org/reference/functions/unregister_taxonomy/
Use it in ‘admin_init’ hook insetead not ‘init’
add_action('admin_menu', 'remove_menu_items');
function remove_menu_items() {
remove_submenu_page('edit.php','edit-tags.php?taxonomy=post_tag');
}