6

I have written some long descriptions for a custom category taxonomy. I don't want to remove them, I just want to hide it from the management page:

/wp-admin/term.php?taxonomy=custom_category

I could use CSS to hide the class "column-description", but I don't know how to only apply it to this taxonomy.

4 Answers 4

10

You could target the edit form for the post_tag taxonomy, through the post_tag_edit_form hook:

/**
 * Hide the term description in the post_tag edit form
 */
add_action( "post_tag_edit_form", function( $tag, $taxonomy )
{ 
    ?><style>.term-description-wrap{display:none;}</style><?php
}, 10, 2 );

Here you can also target an individual tag.

If you need something similar for other taxonomies, you can use the {taxonomy_slug}_edit_form hook.

Update

It looks like the question was about the list tables, not the edit form.

I dug into the list tables in WorPress and found a way to remove the description column from the term table in edit-tags.php

/**
 * Remove the 'description' column from the table in 'edit-tags.php'
 * but only for the 'post_tag' taxonomy
 */
add_filter('manage_edit-post_tag_columns', function ( $columns ) 
{
    if( isset( $columns['description'] ) )
        unset( $columns['description'] );   

    return $columns;
} );

If you want to do the same for other taxonomies, use the manage_edit-{taxonomy_slug}_columns filter.

2
  • thanks for the answer. Wasnt quite what i wanted, but it lit the lightbulb on what i needed to do. I wanted to hide the column from the list of categories. i.e. when you click the post type and then the drop down shows "categories" i wanted to hide the description from this page. used the _add_form_fields hook instead and used the css rule there Feb 17, 2016 at 12:41
  • I updated the answer with a way to remove the 'description' column from the term table. Hopefully I understand this correctly now, if so please correct my previous edits to your question ;-) @DanHastings
    – birgire
    Feb 17, 2016 at 14:02
8

The cleanest way to do that, removing the description field from the edit screen also in the add screen:

function hide_description_row() {
    echo "<style> .term-description-wrap { display:none; } </style>";
}

add_action( "{taxonomy_slug}_edit_form", 'hide_description_row');
add_action( "{taxonomy_slug}_add_form", 'hide_description_row');

Of course you need to replace {taxonomy_slug} with your taxonomy slug.

3
  • 1
    Should be marked as the accepted answer. Oct 11, 2019 at 14:24
  • This is a good answer for hiding the description edit field, but most use cases will probably include hiding the column as well using the manage_edit-{taxonomy_slug}_columns filter.
    – phip
    Aug 30, 2022 at 0:54
  • As far as I see this, this will result in invalid HTML because of the style tags outside of the <head>. See my proposed solution.
    – Merc
    Jun 8, 2023 at 13:04
4

If you also need to hide the description field in the add form use this code

/**
 * Hide the term description in the edit form
 */
add_action( '{taxonomy_slug}_add_form', function( $taxonomy )
{
    ?><style>.term-description-wrap{display:none;}</style><?php
}, 10, 2 );
0

I would propose another solution.


function add_custom_taxonomy_css()
{
  wp_enqueue_style(
    "custom-taxonomy",
    get_stylesheet_directory_uri() . "/custom-taxonomy.css"
  );
}

add_action("exhibitions_edit_form", "add_custom_taxonomy_css");
add_action("exhibitions_add_form", "add_custom_taxonomy_css");

and custom-taxonomy.css

/*
 * hiding taxonomy description
 */

.term-description-wrap {
  display: none;
}

This has, in contrast to the other solution, the advantage, that we still get valid HTML, because we have no stray <style> tags within our <body>.

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.