Limit characters

50 refers to the maximum number of characters.

/* limit characters */
add_action( 'woocommerce_after_shop_loop_item_title', 'lk_woocommerce_product_excerpt', 25);
if (!function_exists('woocommerce_template_single_excerpt'))
{
function lk_woocommerce_product_excerpt()
{
$content_length = 10;
global $post;
$content = $post->post_excerpt;
$wordarray = explode(' ', $content, $content_length + 1);
if(count($wordarray) > $content_length) :
array_pop($wordarray);
array_push($wordarray, '...');
$content = implode(' ', $wordarray);
$content = force_balance_tags($content);
$content = substr($content, 0, 50);
endif;
echo "<div class='archive-excerpt'><p>$content<span>...</span></p></div>";
}
}

Resource: http://stackoverflow.com/questions/23063730/woocommerce-product-description-length-characters

Leave a Reply

Your email address will not be published. Required fields are marked *