in WooCommerce, How can I limit the short product description in the shop page? i added this code:
add_action('woocommerce_after_shop_loop_item_title','woocommerce_template_single_excerpt', 5);
but can't limit it to 40 charachters.
Thanks!!!
in WooCommerce, How can I limit the short product description in the shop page? i added this code:
add_action('woocommerce_after_shop_loop_item_title','woocommerce_template_single_excerpt', 5);
but can't limit it to 40 charachters.
Thanks!!!
Instead of editing files directly within the plugin (which is a very bad idea because once update the plugin and all of your changes will be lost!)
add_filter('woocommerce_short_description', 'limit_woocommerce_short_description', 10, 1);
function limit_woocommerce_short_description($post_excerpt){
if (!is_product()) {
$post_excerpt = substr($post_excerpt, 0, 20);
}
return $post_excerpt;
}
Then paste this in your functions.php file of your theme.
and use this line where you want to display product description -
<?php echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ); ?>
use this code to change Limit on the Shop Page not Product-detailed Page.