WooCommerce: Truncate Short Description With “Read More” Toggle

You can apply this simple jQuery snippet to any piece of WooCommerce content.

In this example we’ll see how to truncate the WooCommerce single product short description and place a “read more” link to reveal the hidden content… however you can also apply this to the long description, a custom product tab, the product gallery, and whatever can be truncated.


After applying the code below, a… long “short description” is now limited to 40 characters and a brand new “Read more” link appears. On click, the hidden text is revealed.

PHP Snippet: Programmatically Truncate Short Description & Replace With “Read More” Link @ WooCommerce Single Product Page

Note: the “show_char” variable defines the number of visible characters of the short description. In the example below I’m using 40.

 * @snippet       Truncate Short Description @ WooCommerce Single
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.7
 * @donate $9     https://businessbloomer.com/bloomer-armada/

add_action( 'wp_footer', 'bbloomer_woocommerce_short_description_truncate_read_more' );

function bbloomer_woocommerce_short_description_truncate_read_more() { 
	if ( ! is_product() ) return;
	<script type="text/javascript">
			var show_char = 40;
			var ellipses = "... ";
			var content = $(".woocommerce-product-details__short-description").html();
			if (content.length > show_char) {
				var a = content.substr(0, show_char);
				var b = content.substr(show_char - content.length);
				var html = a + '<span class="truncated">' + ellipses + '<a href="" class="read-more">Read more</a></span><span class="truncated" style="display:none">' + b + '</span>';

			$(".read-more").click(function(e) {
				$(".woocommerce-product-details__short-description .truncated").toggle();


Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7+.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce Customization?

Check out these free video tutorials. You can start learning how to customize WooCommerce without unnecessary plugins. Watch me code and learn by example!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP

Rodolfo Melogli

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as a WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

14 thoughts on “WooCommerce: Truncate Short Description With “Read More” Toggle

  1. Not working bro!

    Please check and fix this code, thanks

    1. Working for me bro! It could be you need customization

  2. This works perfectly! Thanks. I just got one question. Is there a way to limit the text by word count instead of character count. So it shows not 40 characters but 40 words?

    1. Hi Dennis, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  3. Hi Rodolfo!
    I tried the code but there are certain parts of the short description that do not take and come out of reading more, for example when there are line breaks or bold text.

    If it could be solved, you make me a world

    1. You will need to customize it if you want to target the HTML. This only gets the text (no HTML tags)

  4. How to add and show “read less” link after clicking “read more”

    1. Hi Ibrahim, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  5. This creates a layout issue.
    *It narrows the content. Plz reply.

    1. Screenshot?

  6. Doing this will surely ruin your SEO too. Google isn’t kind to sites that hide their content.

    1. Hello Stef ๐Ÿ™‚ There is nothing sure about SEO. If the product page is informative and you’re hiding little text as opposed to the rest, Google won’t penalize you. Unless you have previous experience with this, in which case I’d be curious. Cheers!

  7. I have tried the code in the descriptions of the categories (I have modified it) but everything is neglected ๐Ÿ™

    1. What code did you use?

Questions? Feedback? Support? Leave your Comment Now!

If you are writing code, please wrap it between: [php]code_here[/php]. Failure to complying with this (as well as going off topic) will result in comment deletion. You should expect a reply in about a week - this is a popular blog but I need to get paid work done first. Please consider joining #BloomerArmada to ask me 1-to-1 WooCommerce questions. Thank you :)

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