Reputation: 3537
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!
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!
Upvotes: 11
Views: 19488
Reputation: 1
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' );
Upvotes: 0
Reputation: 4698
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.
Upvotes: 32
Reputation: 303
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
Upvotes: 10