Reputation: 43
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' );
but it didn't work with woocommerce product short desc
i was trying to use this code
remove_filter( 'woocommerce_single_product_summary', 'wpautop' );
Thank you anyway!
Upvotes: 4
Views: 5961
Reputation: 1
Just like you remove wpautop
in post and pages content, use the same remove filter function, but with correct hook.
remove_filter('woocommerce_short_description','wpautop');
This is all you would need. No fanciness in the functions.php, no creating of additional functions with a hook and then calling remove filter in it. Enjoy!
Upvotes: 0
Reputation: 26319
To remove a filter you have to call that from inside a function that is added to a hook. I don't 100% know why that is, but that seems to be the case. While you can call add_action()
directly in your plugin/theme you cannot call remove_action()
. You can see that the wpauto
is added to the woocommerce_short_description
filter. So to remove it you must do something like the following:
function so_34700299_remote_autop(){
remove_filter( 'woocommerce_short_description', 'wpautop' );
}
add_action( 'wp_head', 'so_34700299_remove_autop' );
Upvotes: 1
Reputation: 65274
you can do it like this...
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);
Note:
wp_strip_all_tags will strip all HTML tags including script and style.
pass second parameter true if you want to remove break tag <br/>
also.
return wp_strip_all_tags( $the_excerpt, true );
Upvotes: 3