Archived topic
How to set word limit for products in merch
3 replies · Started by Subhasish on March 29, 2021
Viewing posts 1–4 of 4
Hi there,
I'm unable to figure out which plugin's shortcode is this [[recent_products limit="3" columns="3"]], I just want to limit the word count of the displaying products.
Hi there,
thats actually controlled by woocommerce - but its simply an excerpt so this PHP Snippet should work:
// Woocommerce shop excerpt length
function woo_shop_excerpt_length( $woo_post_excerpt ) {
if(! is_product() ) {
$description = $woo_post_excerpt;
$wordLength = 10; // set word length
$more = '...'; // more elipses
$woo_post_excerpt = wp_trim_words( $description, $wordLength, $more );
}
return $woo_post_excerpt;
};
add_filter( 'woocommerce_short_description', 'woo_shop_excerpt_length' );
Thanks, working very well, now it's looking good.
You're welcome
This archived topic is closed to new replies.