Question

I am currently developing a theme for Wordpress 3.8.1. As my theme will not display any tags, so I want do disable them (only from the posts, not from custom post types). But how do I do this? I have tried this, but apparently, it does nothing:

register_taxonomy('post_tag', null);

To be clear: I do not just want to hide the tags in the template files, but I want to disable them completely, so in the backend, there is no menu item for tags under posts.

Is it even possible? I hope so. Thanks for your help!

Update

Additionally, I have tried the following, without any effect:

register_taxonomy('post_tag', array());

and

global $wp_taxonomies;
$taxonomy = 'post_tag';
if(taxonomy_exists($taxonomy))
    unset($wp_taxonomies[$taxonomy]);

Both remove the tags box while editing a post, but there still is the link in the menu pointing to the list of tags!

Was it helpful?

Solution

As of WordPress 3.7, there is an unregister_taxonomy_for_object_type function available for just this sort of thing.

In your case:

// Remove tags support from posts
function myprefix_unregister_tags() {
    unregister_taxonomy_for_object_type('post_tag', 'post');
}
add_action('init', 'myprefix_unregister_tags');

View the documentation for this function here.

OTHER TIPS

Paste this code into your functions.php

add_action( 'admin_menu', 'myprefix_remove_meta_box');
function myprefix_remove_meta_box(){
   remove_meta_box( 'tagsdiv-post_tag','post','normal' );
}

tags meta box has a class of tagsdiv-post_tag, so this will remove the tags meta box

OR

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

if you completely want to remove it

The best solution to disable rewrite rules for tags in posts for me was to use the post_tag_rewrite_rules filter hook.

add_filter( 'post_tag_rewrite_rules', '__return_empty_array' );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top