enter image description here

For a custom taxonomy I have created. For each new item, the description field is showing. I would like to hide the description textarea ( Since you can see from the image that I am using an advanced custom field for the description ).

I know there is a way to do it. Can anyone let me know how I can hide the field?

My approach

I did find an answer on SO something like this:

add_action( 'admin_footer-edit-tags.php', 'wpse_56569_remove_cat_tag_description' );

function wpse_56569_remove_cat_tag_description(){
    global $current_screen;
    switch ( $current_screen->id ) 
    {
        case 'edit-category':
            // WE ARE AT /wp-admin/edit-tags.php?taxonomy=category
            // OR AT /wp-admin/edit-tags.php?action=edit&taxonomy=category&tag_ID=1&post_type=post
            break;
        case 'edit-post_tag':
            // WE ARE AT /wp-admin/edit-tags.php?taxonomy=post_tag
            // OR AT /wp-admin/edit-tags.php?action=edit&taxonomy=post_tag&tag_ID=3&post_type=post
            break;
    }
    ?>
    <script type="text/javascript">
    jQuery(document).ready( function($) {
        $('#tag-description').parent().remove();
    });
    </script>
    <?php
}

But did not work.

1 Answer
1

/*remove term descriptions from post editor */

function wpse_hide_cat_descr() { ?>

    <style type="text/css">
       .term-description-wrap {
           display: none;
       }
    </style>

<?php } 

add_action( 'admin_head-term.php', 'wpse_hide_cat_descr' );
add_action( 'admin_head-edit-tags.php', 'wpse_hide_cat_descr' );

If you need to target it to category editor only – in other words leave description for other taxonomies, then easiest will be to position the .taxonomy-category body class before the .term-description-wrap. If for some reason you want to remove only the textarea, it has an ID of #description.

The first action removes the category description box from the category and tags ‘edit’ screens, while the second action removes it from the ‘add new’ screens.

Leave a Reply

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