My client wants to ad line breaks in category description via keyboard enter. In the editor the white space is added, but it is not shown on the website.

I can add it with   but I have to be able to do it by enter key.

I tried commenting out this in default-filters.php:

foreach ( array( 'pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description' ) as $filter ) {
    add_filter( $filter, 'wp_filter_kses' );
}

But it didn’t work. Neither adding this to my functions.php:

$filters = array('pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description');
foreach ( $filters as $filter ) {
    remove_filter($filter, 'wp_filter_kses');
}

Thanks!

2 Answers
2

You can use the standard PHP function nl2br for that

echo nl2br(category_description( $category_id ));

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *