Skip to content

Instantly share code, notes, and snippets.

@jazzsequence
Forked from mattboon/gist:2953889
Last active November 18, 2015 17:51
Show Gist options
  • Save jazzsequence/90db46e3a1430ebe9864 to your computer and use it in GitHub Desktop.
Save jazzsequence/90db46e3a1430ebe9864 to your computer and use it in GitHub Desktop.
WordPress - Remove / unregister taxonomies
<?php
/**
* Unregister taxonomies.
* @param array $taxonomies Optional. An array of taxonomies. If none are given, defaults to post tags and categories.
* @return void
*/
function wds_unregister_taxonomies( $taxonomies = array() ) {
global $wp_taxonomies;
// Allow an array of taxonomies to be passed. Default to tags and categories if nothing was passed.
$taxonomies = ( ! empty( $taxonomies ) && is_array( $taxonomies ) ) ? $taxonomies : array( 'post_tag', 'category' );
foreach ( $taxonomies as $taxonomy ) {
if ( taxonomy_exists( $taxonomy ) ) {
unset( $wp_taxonomies[ $taxonomy ] );
}
}
}
add_action( 'init', 'wds_unregister_taxonomies' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment