1

enter image description hereI registered a custom post type, and then registered a taxonomy to show on the custom post type. When clicking on the taxonomy entry on the post type, I see the edit screen with various native boxes, aka:

Name
Slug
Parent Item
Description

Since I will use ACF exclusively, there is no need to display the description box, or Parent Item box.

Is there a way to remove them? (without using the css display property)

Thank you for any pointers.

1

1 Answer 1

1

Unfortunately not. These items are hard-coded into the wp-admin/edit-tags.php file. The best route is the route you didn't want to go which is CSS.

You can replace category in the below array with a list of taxonomies you want to apply these styles to. The function checks the current taxonomy against this array and if it's found will apply the CSS styles to hide these fields.

/**
 * Hide taxonomy fields per taxonomy
 *
 * @return void
 */
function wpse344725_taxonomy_css() {

    global $taxonomy;

    $modified_tax_arr = array( 'category' );

    if( empty( $taxonomy ) || ! in_array( $taxonomy, $modified_tax_arr ) ) {
        return;
    }

    ?>

        <style>
            .form-field.term-slug-wrap,
            .form-field.term-parent-wrap,
            .form-field.term-description-wrap   {display: none;}
        </style>

    <?php

}
add_action( 'admin_head', 'wpse344725_taxonomy_css' );

Additionally, with the above method you could remove them with JavaScript or hide them with any other CSS visibility property. I can't think of a reason why you wouldn't want to simply hide them in CSS maybe with more elaboration we can find a better solution.

4
  • On my custom taxonomy I have a bunch of fields with instructions on how to properly fill them out. With the WP native fields on the taxonomy the user has the potential to get confused and enter incorrect format/information. I need to hide the field specifically on that page only. It looks like your snippet will hide them on all applicable pages? Also, your above snippet doesn't hide the field, unfortunately.
    – Hewe
    Aug 9, 2019 at 13:26
  • I added a screenshot to the original post. I want to remove the Parent Issue box, and the Description box.
    – Hewe
    Aug 9, 2019 at 14:21
  • Your solution worked, had to switch out category with my taxonomy's name.
    – Hewe
    Aug 9, 2019 at 14:26
  • @Hewe you can add multiple taxonomies to that array, it checks the current taxonomy against that array and if it's in the array it will apply the below styles. I don't think you can get away from keeping Name a shown field. It's a required field for the form.
    – Howdy_McGee
    Aug 9, 2019 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.