8

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

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
}
  • 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 Jun 26 '12 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 Jun 26 '12 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.

  • Ok, to bad. Have to use the jQuery method above then I guess. Thanks. – Johan Dahl Jun 26 '12 at 14:43
  • You're welcome, the jQuery trick will work fine! – Rutwick Gangurde Jun 27 '12 at 8:59
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();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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