Home WooCommerce Tutorials Standard Post

Standard Post

Allow Inserting HTML Code and Images in WooCommerce Category Descriptions

WooCommerce product categories can have category descriptions. Some themes display category description content on the frontend. Many foreign trade websites use category descriptions for on-page SEO optimization. However, by default, WooCommerce category descriptions only support plain text, not HTML, and cannot insert images. We can use the following code to...

Published on October 10, 2022 About 2 minutes read
允许在WooCommerce的分类描述里面插入html代码和图片

WooCommerce product categories can have category descriptions. Some themes will call and display the category description content on the frontend. ManyForeign Trade Independent Websitesuse category descriptions for page SEO optimization. However, by default, WooCommerce category descriptions only support plain text; HTML cannot be used, and images cannot be inserted. We can use the following code to enable HTML support in WooCommerce category 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‘ );
}

Source:https://woocommerce.com/document/allow-html-in-term-category-tag-descriptions/

There is also another plugin that hasn't been tested; interested users can try it:Allow HTML in Category Descriptions

分类添加html权限

Afterwards, you can insert images in category descriptions using HTML code.

1.5/5 - (2 votes)
Previous Plugin-Free Export WooCommerce Orders Tutorial Continue reading content around the same timeline. Next Why Don't SEO Plugins Have a Keywords Option Anymore? View the next related tutorial or experience.

AI Website Building Assistant

🤖
Hello! I am the Naibabiji AI Assistant. How can I help you?
Quick Consultation: