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
}
| improve this answer | |
  • 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;
}
| improve this answer | |
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.

| improve this answer | |
  • 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
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.

| improve this answer | |
0

I used the jQuery below to achieve this as well.

$('label[for="description"]').parent().parent().remove(); 
| improve this answer | |
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();
| improve this answer | |

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.