Allow HTML in term (category, tag) descriptions - WooCommerce
https://woocommerce.com/document/allow-html-in-term-category-tag-descriptions/
Allow HTML in term (category, tag) descriptions
Add code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Code snippets plugin. Avoid adding custom code directly to your parent theme’s functions.php file as this will be wiped entirely when you update the theme.
By default, WordPress strips HTML from category descriptions. This code will prevent that from happening.
/**
* 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' );
}

默认情况下,WordPress会从分类描述中剥离HTML。这段代码可以防止这种情况发生,允许在分类和标签描述中使用HTML。通过在子主题的functions.php文件或使用如Codesnippets的插件添加代码,可以实现这一功能。
490

被折叠的 条评论
为什么被折叠?



