Hide the term description on the term edit page, for a given taxonomy

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.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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.

Method 2

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.

Method 3

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 );


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments