register_taxonomy()Es la herramienta para el trabajo. Del Codex:
Esta función agrega o sobrescribe una taxonomía.
Una opción sería copiarlos register_taxonomy() $argsy modificarlos. Sin embargo, eso significaría que cualquier cambio futuro al register_taxonomy()código original se sobrescribirá.
Por lo tanto, al menos en este caso, es preferible obtener los argumentos originales, modificar los que quiero cambiar y luego volver a registrar la taxonomía. La inspiración para esta solución se dirige a @Otto en esta respuesta a una pregunta similar sobre los tipos de publicaciones personalizadas .
Usando el peopletipo de publicación personalizada y la people_categorytaxonomía del ejemplo, esto lo hará:
function wpse_modify_taxonomy() {
// get the arguments of the already-registered taxonomy
$people_category_args = get_taxonomy( 'people_category' ); // returns an object
// make changes to the args
// in this example there are three changes
// again, note that it's an object
$people_category_args->show_admin_column = true;
$people_category_args->rewrite['slug'] = 'people';
$people_category_args->rewrite['with_front'] = false;
// re-register the taxonomy
register_taxonomy( 'people_category', 'people', (array) $people_category_args );
}
// hook it up to 11 so that it overrides the original register_taxonomy function
add_action( 'init', 'wpse_modify_taxonomy', 11 );
Tenga en cuenta que escribí el tercer register_taxonomy()argumento para el tipo de matriz esperado. Esto no es estrictamente necesario como register_taxonomy()usos wp_parse_args()que pueden manejar un objecto array. Dicho esto, register_taxonomy()'s $argsse supone que deben ser presentados como un arrayacuerdo con el Codex, por lo que este se siente bien para mí.