9

How can I remove the category/taxonomy description field? The one which shows up on the edit category/taxonomy page.

7 Answers 7

6

When no hook is available, you can always count on the old jQuery trickery...

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
}
2
  • Thanks. This works, although I had to add #description to get it to remove the field from the edit category/taxonomy page as well. That feels a bit unsafe though, as anything with ID of description will get removed. Can I be more specific in my targeting? I´m not sure how myself.
    – Johan Dahl
    Commented Jun 26, 2012 at 14:45
  • 1
    Well, the script is only being printed in the edit-tags.php pages. Just checked and as expected only one div with those ID's exist in each page. But I'm adding an extra code to my answer so you are sure of what page you're actually in, tags or categories.
    – brasofilo
    Commented Jun 26, 2012 at 15:07
4

Use CSS, I was implementing the JS solution and I didn't like the delay, then I've remembered about this.

body.taxonomy-name .term-description-wrap {
  display:none;
}
2

AFAIK, you can add new fields but you cannot remove the old ones! They are directly printed, and not stored in a variable to which a filter can be applied. Ref: wp-admin/edit-tags.php, line no. 380.

2
  • Ok, to bad. Have to use the jQuery method above then I guess. Thanks.
    – Johan Dahl
    Commented Jun 26, 2012 at 14:43
  • You're welcome, the jQuery trick will work fine! Commented Jun 27, 2012 at 8:59
1

The most efficient way of 'removing' it is to apply CSS to the admin area, by using the 'admin_head' action hook.

add_action('admin_head', 'my_admin_area_custom_css');

function my_admin_area_custom_css() {
    echo '<style>
        body.taxonomy-name .term-description-wrap {
            display:none;
        }
  </style>';
}

NB: Update the body.taxonomy-name to the taxonomy name you wish to hide the description field for.

There is not a hook to remove the markup from the document, hence hiding it with CSS.

0

I used the jQuery below to achieve this as well.

$('label[for="description"]').parent().parent().remove(); 
0

On the Edit Category/Taxonomy page, .parent() doesn't remove the form field's label. Here's the jQuery for complete removal on both pages:

$('#tag-description').closest('.form-field').remove();
$('#description').closest('.form-field').remove();
0

I guess this would be a good answer

add_filter('manage_edit-product_cat_columns', function ( $columns ) {
    if( isset( $columns['description'] ) )
        unset( $columns['description'] );   
    return $columns;
} );
2
  • This didn't work for me
    – Web Tailor
    Commented Sep 4, 2020 at 10:32
  • @WebTailor try with priority 99, add ",99" before closing that last function bracket Commented Sep 9, 2020 at 12:07

Your Answer

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

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