woocommerce 产品摘录说明(简短) [英] woocommerce product excerpt description (short)
问题描述
我想删除 woocommerce 产品简短描述中的 wordpress html-formatting.它到处添加 p 标签.我知道如何在 wp 帖子和页面中做到这一点
I want to remove wordpress html-formatting in woocommerce product short description. It add p tag everywhere. I know how to do it in wp posts and pages
remove_filter('the_excerpt', 'wpautop');
remove_filter( 'the_excerpt', 'wpautop' );
但它不适用于 woocommerce 产品简短描述
but it didn't work with woocommerce product short desc
我正在尝试使用此代码
remove_filter('woocommerce_single_product_summary', 'wpautop');
remove_filter( 'woocommerce_single_product_summary', 'wpautop' );
还是谢谢你!
推荐答案
你可以这样做...
function rei_woocommerce_short_description($the_excerpt) {
return wp_strip_all_tags($the_excerpt);
}
add_filter('woocommerce_short_description', 'rei_woocommerce_short_description',10, 1);
注意:
wp_strip_all_tags 将删除所有 HTML 标签,包括脚本和样式.
wp_strip_all_tags will strip all HTML tags including script and style.
如果您还想删除中断标记 <br/>
,则传递第二个参数 true.
pass second parameter true if you want to remove break tag <br/>
also.
return wp_strip_all_tags( $the_excerpt, true );
这篇关于woocommerce 产品摘录说明(简短)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!