Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1428661

    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.

    #1428707

    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

    #1429131

    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?

    #1429155

    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

    #1429177

    Hi Nikko,
    Thank you that has done the trick

    • This reply was modified 11 months, 2 weeks ago by Dave.
    #1429180

    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

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Product Short Description – Woo commerce’ is closed to new replies.