-
-
Save jazzsequence/90db46e3a1430ebe9864 to your computer and use it in GitHub Desktop.
WordPress - Remove / unregister taxonomies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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