register_taxonomy_args
Allows you to change the arguments specified when registering a taxonomy.
See register_taxonomy for all parameters passed through the register_taxonomy_args filter hook.
Usage
add_filter( 'register_taxonomy_args', 'wp_kama_register_taxonomy_args_filter', 10, 3 );
/**
* Function for `register_taxonomy_args` filter-hook.
*
* @param array $args Array of arguments for registering a taxonomy. See the register_taxonomy() function for accepted arguments.
* @param string $taxonomy Taxonomy key.
* @param string[] $object_type Array of names of object types for the taxonomy.
*
* @return array
*/
function wp_kama_register_taxonomy_args_filter( $args, $taxonomy, $object_type ){
// filter...
return $args;
}
- $args(array)
- An array of parameters specified when registering the taxonomy.
- $taxonomy(string)
- The taxonomy key (name).
- $object_type(array)
- An array of names of the post types associated with the taxonomy.
Examples
#1 Remove the category selection meta box when editing a Post
add_filter( 'register_taxonomy_args', 'register_taxonomy_args', 10, 2 );
function register_taxonomy_args( $args, $taxonomy ) {
if ( 'category' === $taxonomy ) {
$args['meta_box_cb'] = false; // For the visual editor
$args['show_in_rest'] = false; // For the block editor
}
return $args;
}Changelog
| Since 4.4.0 | Introduced. |
Where the hook is called
register_taxonomy_args
wp-includes/class-wp-taxonomy.php 316
$args = apply_filters( 'register_taxonomy_args', $args, $this->name, (array) $object_type );