Skip to content

Instantly share code, notes, and snippets.

@jacobwise
Last active May 6, 2021 19:26
Show Gist options
  • Select an option

  • Save jacobwise/c4cb6192e15268a7a2e1 to your computer and use it in GitHub Desktop.

Select an option

Save jacobwise/c4cb6192e15268a7a2e1 to your computer and use it in GitHub Desktop.
How to remove the category description column
/**
* Remove default description column from category
*
*/
function jw_remove_taxonomy_description($columns)
{
// only edit the columns on the current taxonomy, replace category with your custom taxonomy (don't forget to change in the filter as well)
if ( !isset($_GET['taxonomy']) || $_GET['taxonomy'] != 'category' )
return $columns;
// unset the description columns
if ( $posts = $columns['description'] ){ unset($columns['description']); }
return $columns;
}
add_filter('manage_edit-category_columns','jw_remove_taxonomy_description');
@jessedmatlock
Copy link
Copy Markdown

If you just want to truncate the description, in those cases when it's long but you still want to see it in the admin table, use this:

add_action( 'admin_head-edit-tags.php', 'admin_edit_tags' );
function admin_edit_tags() {
    add_filter( 'get_terms', 'admin_trim_category_description', 10, 2 );
}
    function admin_trim_category_description( $terms, $taxonomies ) {
	if ( !is_admin())
	        return;
	
    if( 'category' != $taxonomies[0] )
        return $terms;
    foreach( $terms as $key=>$term )
        // change 150 to the character length you want to trim the desc to
        $terms[$key]->description = substr( $term->description, 0, 150 );
    return $terms;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment