register_taxonomy
触发操作registered_taxonomy
在它注册之后,它会立即提供它注册时使用的参数。只要分类键不变,就可以挂接该操作,修改参数,然后重新注册它。
function wpd_update_taxonomy_args( $taxonomy, $object_type, $args ){
if( \'plugin_tax\' == $taxonomy ){
// remove this action so we don\'t create an infinite loop!
remove_action( current_action(), __FUNCTION__ );
// change arguments
$args[\'rewrite\'] = array( \'slug\' => \'foobar\' );
// re-register
register_taxonomy( $taxonomy, $object_type, $args );
}
}
add_action( \'registered_taxonomy\', \'wpd_update_taxonomy_args\', 10, 3 );