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 meta_box_cb, 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.

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

Author: Daron

Professional WordPress enthusiast and developer. When not doing WordPress, he enjoys Netflix and playing Nintendo. He is also available for freelance opportunities. Get in touch to hash out the details.

Leave a Reply

Your email address will not be published. Required fields are marked *