{"id":32489,"date":"2024-03-05T13:09:03","date_gmt":"2024-03-05T08:09:03","guid":{"rendered":"https:\/\/mcstarters.com\/blog\/?p=32489"},"modified":"2024-03-05T13:09:05","modified_gmt":"2024-03-05T08:09:05","slug":"truncate-short-description","status":"publish","type":"post","link":"https:\/\/mcstarters.com\/blog\/truncate-short-description\/","title":{"rendered":"How To Truncate Short Description With \u201cRead More\u201d Toggle in WooCommerce?"},"content":{"rendered":"\n<p>How to Truncate Short Description With \u201cRead More\u201d Toggle in WooCommerce?<\/p>\n\n\n\n<p>Providing an engaging and streamlined shopping experience is crucial for customer satisfaction. WooCommerce, the popular WordPress e-commerce plugin, offers a plethora of customization options. <\/p>\n\n\n\n<p class=\"bg-light\"><a href=\"https:\/\/mcstarters.com\/blog\/?p=32468\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/mcstarters.com\/blog\/?p=32468\" rel=\"noreferrer noopener\">Display Long Descriptions Instead Of Short Ones on Single Product Pages<\/a><\/p>\n\n\n\n<p>In this blog post, we&#8217;ll explore a simple yet effective technique to truncate the short description of your products and incorporate a <strong>&#8220;<\/strong>Read More<strong>&#8221; <\/strong>toggle, ensuring a cleaner and more user-friendly product page.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Truncate?<\/h2>\n\n\n\n<p>When it comes to showcasing product information, brevity is often key. A concise product description provides a quick overview, enticing potential buyers to explore further. However, for those instances where additional details are necessary, a &#8220;Read More&#8221; option comes in handy, striking a balance between informativeness and a clutter-free interface.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Truncate Short Description With \u201cRead More\u201d Toggle in WooCommerce<\/h2>\n\n\n\n<p>Truncate short description in WooCommerce with ease using a &#8216;Read More&#8217; toggle. Enhance user experience and maintain a clean product page. Follow our step-by-step guide for seamless customization.<\/p>\n\n\n\n<p class=\"step\"><strong>Step 1:<\/strong> Log in to your WordPress admin panel. Go to <strong>&#8220;<\/strong>Appearance<strong>&#8221; <\/strong>-&gt; <strong>&#8220;<\/strong>Theme Editor.<strong>&#8220;<\/strong><\/p>\n\n\n\n<p class=\"step\"><strong>Step 2:<\/strong> Locate and select the <strong>&#8220;<\/strong>Theme Functions<strong>&#8221; <\/strong>file or <code>functions.php<\/code> your child theme.<\/p>\n\n\n\n<p class=\"step\"><strong>Step 3: <\/strong>Copy the provided PHP code and paste it at the end of the selected file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/*\n Description: Truncate Short Description @ WooCommerce Single Author: Mudassar Shakeel\n Websites:https:\/\/mcstarters.com\/\n*\/\n \nadd_action( 'woocommerce_after_single_product', 'mcstarters_woocommerce_short_description_truncate_read_more' );\n \nfunction mcstarters_woocommerce_short_description_truncate_read_more() { \n   wc_enqueue_js( '\n      var show_char = 40;\n      var ellipses = \"... \";\n      var content = $(\".woocommerce-product-details__short-description\").html();\n      if (content.length &gt; show_char) {\n         var a = content.substr(0, show_char);\n         var b = content.substr(show_char - content.length);\n         var html = a + \"&lt;span class=\\'truncated\\'&gt;\" + ellipses + \"&lt;a class=\\'read-more\\'&gt;Read more&lt;\/a&gt;&lt;\/span&gt;&lt;span class=\\'truncated\\' style=\\'display:none\\'&gt;\" + b + \"&lt;\/span&gt;\";\n         $(\".woocommerce-product-details__short-description\").html(html);\n      }\n      $(\".read-more\").click(function(e) {\n         e.preventDefault();\n         $(\".woocommerce-product-details__short-description .truncated\").toggle();\n      });\n   ' );\n}<\/code><\/pre>\n\n\n\n<p class=\"step\"><strong>Step 4:<\/strong> Click the &#8220;Update File&#8221; button to save your changes.<\/p>\n\n\n\n<p>After implementing the code, visit your WooCommerce product pages and ensure that the short descriptions are truncated as intended. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusions<\/h2>\n\n\n\n<p>Enhance the user experience on your WooCommerce store by implementing this &#8220;Read More&#8221; toggle for truncated short descriptions. Your customers will appreciate the clean design and easy access to additional product details. Happy selling!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">FAQs<\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1709534445663\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">What is the purpose of the &#8220;Read More&#8221; toggle?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>The &#8220;Read More&#8221; toggle is a feature that allows users to view the full content of a truncated short description. By clicking the &#8220;Read More&#8221; link, additional text is revealed, giving customers the option to explore more details about the product without cluttering the initial view.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1709534494638\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">How to truncate long text and show the read more \/ less button?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Truncating long text and implementing a &#8220;Read More \/ Read Less&#8221; button in HTML and JavaScript can be achieved with a few lines of the above code.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>How to Truncate Short Description With \u201cRead More\u201d Toggle in&#8230;<\/p>\n","protected":false},"author":2,"featured_media":32501,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[68],"tags":[536],"class_list":["post-32489","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-woocommerce","tag-woocommerce-tips"],"_links":{"self":[{"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/posts\/32489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/comments?post=32489"}],"version-history":[{"count":0,"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/posts\/32489\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/media\/32501"}],"wp:attachment":[{"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/media?parent=32489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/categories?post=32489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/tags?post=32489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}