Modifying Custom Taxonomy Forms in WordPress

Today, I was working on a client project and needed to add a little snippet underneath a hierarchical taxonomy form that was registered on a custom post type. Unfortunately, after spending about ten minutes digging through core and googling, I couldn't find an action hook to use. Luckily, after tracing the output a little further back, I found what I was looking for.

When registering a custom taxonomy, one of the oft forgotten arguments is metaboxcb, or the callback function used to render the meta box in the admin edit screen. Tracing this back a little further, the default value is set in wp-includes/taxonomy.php on Line 454. Using one of those default functions within our custom callback, we can essentially add as much code before or after the default taxonomy form.

https://gist.github.com/Daronspence/630075c69e658c7ce273

It's that simple! If you need to add something to the non-hierarchical taxonomy form, simply swap out line 9 for the posttagsmeta_box() function instead.

Posted in:

WordPress