Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[Frontend Snippets] Allow HTML in term (category, tag) descriptions
/**
* Allow HTML in term (category, tag) descriptions
*/
foreach ( array( 'pre_term_description' ) as $filter ) {
remove_filter( $filter, 'wp_filter_kses' );
if ( ! current_user_can( 'unfiltered_html' ) ) {
add_filter( $filter, 'wp_filter_post_kses' );
}
}
foreach ( array( 'term_description' ) as $filter ) {
remove_filter( $filter, 'wp_kses_data' );
}
@TommiContursi

This comment has been minimized.

Copy link

@TommiContursi TommiContursi commented Apr 16, 2018

Do you know the same kind of filter for allowing HTML in a description of a custom field on the checkout page? I'm trying to add a field for VAT number, and I need to have a link in the description.

@Rsmith-gs

This comment has been minimized.

Copy link

@Rsmith-gs Rsmith-gs commented Oct 2, 2018

I'm having trouble getting this to work now on version 3.4.5.

@bomakalu

This comment has been minimized.

Copy link

@bomakalu bomakalu commented Mar 4, 2020

This doesnt work in the latest version march 202

@ArneSaknussemm

This comment has been minimized.

Copy link

@ArneSaknussemm ArneSaknussemm commented Jul 27, 2021

Why do you loop in a single element array?
The term_description function doesn't do that filter. Maybe was deprecated.

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