OhhMuaOhhMua
  • Home
  • Hosting
    • Best Web Hosting
    • Free Web Hosting
    • VPS Hosting
  • WordPress
    • Solutions & Troubleshooting
    • Installation & Setup
    • Themes & Plugins
    • Security
  • Computer Tips
    • Gaming Errors & Solutions
    • PC Troubleshooting
    • Computer Hardware
  • Coupons & Deals
  • Contact Us
Reading: How to Add a “Read More” and “Show Less” Button to Product Descriptions in WooCommerce
Share
Notification Show More
Font ResizerAa
OhhMuaOhhMua
Font ResizerAa
  • Computer Tips
  • Hosting
  • WordPress
Search
  • Home
  • WordPress
    • Installation & Setup
    • Security
    • Solutions & Troubleshooting
    • Themes & Plugins
    • Troubleshooting
  • Hosting
    • Free Web Hosting
    • VPS Hosting
    • Best Web Hosting
  • Computer Tips
    • PC Troubleshooting
    • Gaming Errors & Solutions
    • Computer Hardware
  • Coupons & Deals
Have an existing account? Sign In
Follow US
Copyright © 2024 ohhmua. All rights reserved.
OhhMua > Blog > WordPress > Solutions & Troubleshooting > How to Add a “Read More” and “Show Less” Button to Product Descriptions in WooCommerce
Solutions & Troubleshooting

How to Add a “Read More” and “Show Less” Button to Product Descriptions in WooCommerce

ohhmua
Last updated: May 5, 2025 4:09 pm
ohhmua
Share
5 Min Read
How to Add a Read More to Product Descriptions in WooCommerce
How to Add a Read More to Product Descriptions in WooCommerce
SHARE
Contents
✅ Why Use a “Read More” Button?🛠️ How to Implement📋 How to Use🌟 Highlighted Features✅ Conclusion

In this tutorial, I’ll show you how to add a “Read More” and “Show Less” button to your WooCommerce product description. This feature is especially useful for products with long descriptions, helping to keep the product page clean and user-friendly.

✅ Why Use a “Read More” Button?

  • Improve UX: Let users decide whether they want to see the full product description.

  • Optimize Layout: Keeps the page neat and focused by reducing visual clutter.

  • Faster Load Time: Minimizes initial content height, which speeds up page rendering.

  • Increase Engagement: Adds interactivity and encourages users to explore more product details.

🛠️ How to Implement

Below is the full code to add the “Read More” and “Show Less” functionality to your WooCommerce product description.

<?php
add_action('wp_footer', 'wat_product_description_expand_feature');
function wat_product_description_expand_feature() {
    if (!is_product()) return;
    ?>
    <style>
        .single-product div#tab-description {
            position: relative;
            overflow: hidden;
            padding-bottom: 30px;
        }

        .wat-description-collapsed {
            max-height: 800px;
            overflow: hidden;
            position: relative;
        }

        .single-product .tab-panels div#tab-description.panel:not(.active) {
            height: 0 !important;
        }

        .wat-description-toggle-button {
            text-align: center;
            cursor: pointer;
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            z-index: 999;
            background-color: #fff;
        }

        .wat-read-more-button:before {
            content: "";
            height: 60px;
            margin-top: -50px;
            display: block;
            background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,1));
        }

        .wat-description-toggle-button a {
            color: #0057b8;
            display: block;
            padding: 5px 0;
            font-weight: 500;
        }

        .wat-description-toggle-button a:after {
            content: '';
            display: inline-block;
            width: 0;
            height: 0;
            margin-left: 8px;
            vertical-align: middle;
            border-left: 5px solid transparent;
            border-right: 5px solid transparent;
        }

        .wat-read-more-button a:after {
            border-top: 5px solid #0057b8;
        }

        .wat-read-less-button a:after {
            border-bottom: 5px solid #0057b8;
        }

        .wat-read-less-button:before {
            display: none;
        }
    </style>

    <script>
        (function($) {
            $(document).ready(function() {
                var $description = $('.single-product div#tab-description');

                if ($description.length > 0) {
                    var actualHeight = $description.outerHeight();
                    var maxHeight = 800;

                    if (actualHeight > maxHeight) {
                        $description.addClass('wat-description-collapsed');

                        var $readMoreBtn = $('<div class="wat-description-toggle-button wat-read-more-button"><a href="javascript:void(0);">Read More</a></div>');
                        $description.append($readMoreBtn);

                        var $readLessBtn = $('<div class="wat-description-toggle-button wat-read-less-button" style="display: none;"><a href="javascript:void(0);">Show Less</a></div>');
                        $description.append($readLessBtn);

                        $readMoreBtn.on('click', function() {
                            $description.removeClass('wat-description-collapsed');
                            $readMoreBtn.hide();
                            $readLessBtn.show();
                        });

                        $readLessBtn.on('click', function() {
                            $description.addClass('wat-description-collapsed');
                            $readLessBtn.hide();
                            $readMoreBtn.show();
                            $('html, body').animate({
                                scrollTop: $description.offset().top - 100
                            }, 300);
                        });
                    }
                }
            });
        })(jQuery);
    </script>
    <?php
}
?>

📋 How to Use

  1. Paste into functions.php
    Add the code above to your child theme’s functions.php file.

  2. Customize the Max Height
    The line var maxHeight = 800; sets the max height in pixels before showing the “Read More” button. Adjust this to suit your layout.

  3. Customize Colors
    Change the color #0057b8 in the CSS to match your theme.

  4. Edit Button Text
    Update the button labels:

var $readMoreBtn = $('<div class="wat-description-toggle-button wat-read-more-button"><a href="javascript:void(0);">Read More</a></div>');
var $readLessBtn = $('<div class="wat-description-toggle-button wat-read-less-button" style="display: none;"><a href="javascript:void(0);">Show Less</a></div>');

🌟 Highlighted Features

  • Auto Detection: The script only activates when the description exceeds the height threshold.

  • Fade Effect: Adds a gradient fade at the bottom for a smooth visual cue.

  • Auto Scroll: When collapsing, the page scrolls back to the top of the description.

  • Efficient: Runs only on single product pages, so it doesn’t affect performance site-wide.

    Read more: Protecting Your WordPress Site from File Upload Vulnerabilities

✅ Conclusion

By using this code, you can enhance your WooCommerce store with an elegant “Read More / Show Less” feature. It helps improve the user experience, keeps your layout clean, and makes your long product descriptions more manageable.

Feel free to customize the design and behavior to suit your theme. Good luck—and happy optimizing!

You Might Also Like

Cannot Fetch Sitemap in Google Search Console

Discovered – Currently Not Indexed in Google Search Console: What It Means & How to Fix It

Why 2 Backlinks per Article Might Be Killing Your SEO

What is Obsidian? Why Developers Love This Note-Taking App

Want Faster Load Times? Optimize WordPress This Way

Share This Article
Facebook Twitter Email Print
Leave a comment Leave a comment

Leave a Reply Cancel reply

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

Trending

The detailed guide to installing a second SSD in your computer [Full A Z]
Computer Hardware

The detailed guide to installing a second SSD in your computer [Full A-Z]

August 11, 2020
Fixing hasMerchantReturnPolicy and shippingDetails error for WooCommerce
Solutions & Troubleshooting

Fixing hasMerchantReturnPolicy and shippingDetails error for WooCommerce

September 14, 2024
Discovered – Currently Not Indexed in Google Search Console
Solutions & Troubleshooting

Discovered – Currently Not Indexed in Google Search Console: What It Means & How to Fix It

May 25, 2025
How to Fix Red Alert 2 Black Screen Issue on Windows 10,11
Gaming Errors & Solutions

How to Fix Red Alert 2 Black Screen Issue on Windows 10,11

September 18, 2024
5 Signs Your SSD is About to Fail and How to Extend Its Lifespan
Computer Hardware

5 Signs Your SSD is About to Fail and How to Extend Its Lifespan

August 6, 2020
Guide to Choosing the Best Gaming CPU
Computer Hardware

Guide to Choosing the Best Gaming CPU

July 28, 2020
Previous Next

You Might Also Like

My Google Discover traffic skyrocketed after I did these 10 things
Solutions & Troubleshooting

My Google Discover traffic skyrocketed after I did these 10 things

May 14, 2025
WordPress Covers Every Website Type
Solutions & Troubleshooting

Blog, E-Commerce, or Forum? WordPress Covers Every Website Type!

April 29, 2025
Optimized Pagination thumbnail
Solutions & Troubleshooting

How I Optimized Pagination and Skyrocketed Traffic

April 28, 2025
How to Pick the Ideal Blogging Platform for Your Needs
Solutions & Troubleshooting

How to Pick the Ideal Blogging Platform for Your Needs

April 1, 2025
Previous Next
newsletter featured

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!

Follow US on Social Media

Facebook Youtube Steam Twitch Unity

Copyright © 2024 ohhmua. All rights reserved.

OhhMua

Information

  • About
  • Terms & Conditions
  • Privacy Policy
Welcome Back!

Sign in to your account

Lost your password?