I am using enfolds Products List content element and adding product details into the ‘Product Short Description’ however I would like to limit the text length it displays on the listings I have seen function code for the Product Description but not the ‘Product Short Description’ can any one assist me with this please.
Hi Dave,
Please try the codes provided in this link: https://stackoverflow.com/questions/38155544/limit-product-short-description-length-in-woocommerce
Hope it helps.
Best regards,
Nikko
Hi Nikko, thank you for the link but unfortunately I have tried the code and it doesn’t seem to work. I am using enfolds product list could this be why it isn’t working or is it due to the code being old? Any other code i could look into please?
Hi Dave,
Can you try this code:
function product_excerpt_length($excerpt, $post) {
$excerpt_length = 10;
if ($post->post_type === 'product') {
$excerpt = explode(' ', $excerpt);
$excerpt = implode(' ', array_slice($excerpt, 0, $excerpt_length));
}
return $excerpt;
}
add_filter('get_the_excerpt', 'product_excerpt_length', 10, 2);
Just change the $excerpt_length value, which is the number of words that should appear in maximum.
Best regards,
Nikko
Hi Nikko,
Thank you that has done the trick
Hi,
Glad Nikko was able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.
Best regards,
Mike