X

Remove Default Taxonomies (Categories, Tags)

This is a great snippet if you need to customize your WordPress Admin just a little bit. For example, if you aren't interested in having WordPress' default taxonomies (categories and tags) on your blog posts, and, therefore, don't want those unused options cluttering up your backend.

First, remove the default taxonomies categories, tags from the Admin menu. Now, because this only removes the menu item if you visit the URL edit-tags.php?taxonomy=post_tag, you’ll still have access to tags and categories. Next, check the $pagenow to see if you're on edit-tags.php. Then, check taxonomy=post_tag to see if it’s post_tag or category and return with an error. Just add this snippet to the functions.php of your WordPress theme and you’re all set.


function wpsnipp_remove_default_taxonomies(){
    global $pagenow;

    register_taxonomy( 'post_tag', array() );
    register_taxonomy( 'category', array() );

    $tax = array('post_tag','category');

    if($pagenow == 'edit-tags.php' && in_array($_GET['taxonomy'],$tax) ){
	wp_die('Invalid taxonomy');
    }
}
add_action('init', 'wpsnipp_remove_default_taxonomies');


Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!
[63% OFF Today!]
[63% OFF Today!]
[63% OFF Today!]
[63% OFF Today!]
[63% OFF Today!]
[63% OFF Today!]
[60% OFF Today!]
[60% OFF Today!]
[50% OFF Today!]
[50% OFF Today!]