Last active
June 21, 2019 21:44
-
-
Save franz-josef-kaiser/870890 to your computer and use it in GitHub Desktop.
Allows unregistering built in wordpress taxonomies like 'post_tag', 'taxonomy', etc.
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 | |
/** | |
* Plugin Name: Remove Builtin WP Taxonomies | |
*/ | |
add_action( 'init', 'unregister_taxonomy' ); | |
/** | |
* Remove built in taxonomies | |
* @author: Franz Josef Kaiser | |
*/ | |
function unregister_taxonomy( $taxonomy ) | |
{ | |
global $wp_taxonomies; | |
foreach ( wp_list_pluck( $wp_taxonomies, '_builtin' ) ) as $tax => $data ) | |
{ | |
// Now let's unset "category" | |
if ( $tax === 'category') | |
{ | |
// Check to be sure if we're dealing with the right one | |
# print_r( $tax ); | |
unset( $wp_taxonomies[ $tax ] ); | |
} | |
} | |
} | |
add_action( 'wp_footer', 'check_unset_category', 999 ); | |
function check_unset_category() | |
{ | |
defined( 'WP_DEBUG' ) | |
AND WP_DEBUG | |
AND printf( '<pre>%s</pre>', $GLOBALS['wp_taxonomies'] ); | |
} |
You're foreach
loop has an extra )
in it:
foreach ( wp_list_pluck( $wp_taxonomies, '_builtin' ) ) as $tax => $data )
Should be:
foreach ( wp_list_pluck( $wp_taxonomies, '_builtin' ) as $tax => $data )
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hola, lo siento pero no me funcionó, quizá hice algo malo, de todas formas te dejo aquí un código que si me sirvió en WP4.4.
Saludos