user3436092 user3436092 - 1 year ago 103
PHP Question

WooCommerce allowing html syntax in category description field

I'm using a themeforest theme for my new WooCommerce store.

While I go to edit category there's a description field which doesn't allow html tags.

My question: How can I make this field accepting html tags?

So I can put a banner image and centralize text etc…

I do not want to use any plugin as there are already available.

What would I need to do to enable text editor inside description field?

Answer Source

wp_filter_kses() function filters the description in WP / WC categories. So what you need is disabling that filter.

You will need to add this code to your function.php file (located in your active theme folder):

foreach ( array( 'pre_term_description' ) as $filter ) { 
    remove_filter( $filter, 'wp_filter_kses' ); 
foreach ( array( 'term_description' ) as $filter ) { 
    remove_filter( $filter, 'wp_kses_data' ); 

You can't enable (and don't need) the rich text editor in that description category field, but after adding the code above, you will be able to add html effective tags (like a banner image or other html tags…)

Advice: Is better to enable a chid theme (based on your active theme), then when adding code to the funcion.php file of your child theme, you will not lose anything, when the theme get updated…

This post is related to: Wordpress Category Descriptions - HTML?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download