Truncate description within categories admin panel

Adding this snippet to the functions.php of your wordpress theme will truncate the description displayed within the categories admin panel to 150 characters. Change the number 150 on line 09 to adjust the number of characters for the category description.

 

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( 'category' != $taxonomies[0] )
return $terms;
foreach( $terms as $key=>$term )
$terms[$key]->description = substr( $term->description, 0, 150 );
return $terms;
}

Be Sociable, Share!

Leave a comment