OhhMuaOhhMua
  • Home
  • Hosting
    • Best Web Hosting
    • Free Web Hosting
    • VPS Hosting
  • WordPress
    • Solutions & Troubleshooting
    • Installation & Setup
    • Themes & Plugins
    • Security
  • Build PC
    • High-end Builds
    • Mid-range Builds
    • Entry-level Builds
  • Computer Tips
    • Gaming Errors & Solutions
    • PC Troubleshooting
    • Hardware Tips
    • Computer Hardware
  • Coupons & Deals
  • Tools
    • veo3 prompt generator
Reading: How to Add a “Read More” and “Show Less” Button to Product Descriptions in WooCommerce
Notification Show More
OhhMuaOhhMua
  • 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
  • veo3 prompt generator
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

Admin (Nghia Vo)
Last updated: May 5, 2025 4:09 pm
Admin (Nghia Vo)
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!

480520387 657957633334779 6814038772835954285 n
Admin (Nghia Vo)

Hi, I’m Nghia Vo: a computer hardware graduate, passionate PC hardware blogger, and entrepreneur with extensive hands-on experience building and upgrading computers for gaming, productivity, and business operations.

As the founder of Vonebuy.com, a verified ecommerce store under Vietnam’s Ministry of Industry and Trade, I combine my technical knowledge with real-world business applications to help users make confident decisions.

I specialize in no-nonsense guides on RAM overclocking, motherboard compatibility, SSD upgrades, and honest product reviews sharing everything I’ve tested and implemented for my customers and readers.

You Might Also Like

SEO in the Age of AI: How to Make Google Understand and Value Your Content

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

Share This Article
Facebook Twitter Email Print
By Admin (Nghia Vo)
Follow:

Hi, I’m Nghia Vo: a computer hardware graduate, passionate PC hardware blogger, and entrepreneur with extensive hands-on experience building and upgrading computers for gaming, productivity, and business operations.

As the founder of Vonebuy.com, a verified ecommerce store under Vietnam's Ministry of Industry and Trade, I combine my technical knowledge with real-world business applications to help users make confident decisions. I specialize in no-nonsense guides on RAM overclocking, motherboard compatibility, SSD upgrades, and honest product reviews sharing everything I’ve tested and implemented for my customers and readers.
Leave a comment Leave a comment

Leave a Reply Cancel reply

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

Trending

Comprehensive Computer Beep Codes [Help You Fix Errors]
Computer Hardware

Comprehensive Computer Beep Codes [Help You Fix Errors]

August 22, 2020
Share a countdown button to display a password in WordPress
Solutions & Troubleshooting

Share a countdown button to display a password in WordPress

September 11, 2024
Why 2 Backlinks per Article Might Be Killing Your SEO
Solutions & Troubleshooting

Why 2 Backlinks per Article Might Be Killing Your SEO

May 23, 2025
How to Increase the Star Ratings for KK Star Ratings 1
Solutions & Troubleshooting

How to Increase the Star Ratings for KK Star Ratings

September 8, 2024
what is computer hardware
Computer Hardware

What is Computer Hardware? Everything You Need to Know

August 23, 2020
Cannot Fetch Sitemap in Google Search Console
Solutions & Troubleshooting

Cannot Fetch Sitemap in Google Search Console

May 27, 2025
Previous Next

You Might Also Like

Optimize WordPress
Solutions & Troubleshooting

Want Faster Load Times? Optimize WordPress This Way

May 16, 2025
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
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?