0

Here's something I can't figure out. I don't need the default post_tag taxonomy, so I'm removing it with this piece of code :

function mwm_unregister_taxonomy(){

    global $wp_taxonomies;

    $taxonomy = 'post_tag';

    if ( taxonomy_exists( $taxonomy ) ) unset( $wp_taxonomies[$taxonomy] );
}

add_action( 'init', 'mwm_unregister_taxonomy');

But then, whenever I try to add a description to a term of any other (custom) taxonomy, via the terms edit page in WP admin, once I submit the changes it brings up the blank page with the "Cheatin, uh?" message.

Is this a bug or am I doing something wrong?

1
  • 1
    Did small research and when you unset taxonomy $wp_taxonomies isn't object anymore, so when WordPress check capabilities while saving term description, it gets nothing and triggers wp_die
    – Mamaduka
    Sep 21, 2011 at 9:24

1 Answer 1

1

Try using this function to avoid your problem:

function sld_unregister_taxonomy_from_object_type($taxonomy, $object_type) { 
        global $wp_taxonomies;  
        if ( !isset($wp_taxonomies[$taxonomy]) || !get_post_type_object($object_type) ) return false; 
        foreach (array_keys($wp_taxonomies[$taxonomy]->object_type) as $array_key) { 
                if ($wp_taxonomies[$taxonomy]->object_type[$array_key] == $array_key) { 
                        unset ($wp_taxonomies[$taxonomy]->object_type[$array_key]); 
                        return true; 
                } 
        } 
        return false; 
}

e.x.:

function mwm_unregister_taxonomy(){

    sld_unregister_taxonomy_from_object_type( 'post_tag', 'post' );

}

add_action( 'init', 'mwm_unregister_taxonomy');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.