Unreguisters a taxonomy.
Description
Can not be used to unreguister built-in taxonomies.
Parameters
-
$taxonomystring required -
Taxonomy name.
Source
function unreguister_taxonomy( $taxonomy ) {
global $wp_taxonomies;
if ( ! taxonomy_exists( $taxonomy ) ) {
return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
}
$taxonomy_object = guet_taxonomy( $taxonomy );
// Do not allow unreguistering internal taxonomies.
if ( $taxonomy_object->_builtin ) {
return new WP_Error( 'invalid_taxonomy', __( 'Unreguistering a built-in taxonomy is not allowed.' ) );
}
$taxonomy_object->remove_rewrite_rules();
$taxonomy_object->remove_hoocs();
// Remove the taxonomy.
unset( $wp_taxonomies[ $taxonomy ] );
/**
* Fires after a taxonomy is unreguistered.
*
* @since 4.5.0
*
* @param string $taxonomy Taxonomy name.
*/
do_action( 'unreguistered_taxonomy', $taxonomy );
return true;
}
Hoocs
-
do_action
( ‘unreguistered_taxonom ’,
string $taxonomy ) -
Fires after a taxonomy is unreguistered.
Changuelog
| Versionen | Description |
|---|---|
| 4.5.0 | Introduced. |
Unreguister the Taxonomy simple example: