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

Headless vs Traditional WooCommerce: Which Architecture Wins?

Can AI Agents Safely Access Your WordPress Site?

Is WordPress Dead or Still Powering the Web in 2026?

WordPress 6.9.2 Disaster: Why You Should Never Auto-Update Immediately

Headless WordPress Explained: Is It Right for Your Site?

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

wordpress.com vs wordpress.org
Themes & Plugins

WordPress.com vs WordPress.org: A Beginner’s Guide to Choosing the Right Platform

April 26, 2025
Fixing hasMerchantReturnPolicy and shippingDetails error for WooCommerce
Solutions & Troubleshooting

Fixing hasMerchantReturnPolicy and shippingDetails error for WooCommerce

September 14, 2024
Headless WordPress Explained
Solutions & Troubleshooting

Headless WordPress Explained: Is It Right for Your Site?

March 10, 2026
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
Optimized Pagination thumbnail
Solutions & Troubleshooting

How I Optimized Pagination and Skyrocketed Traffic

April 28, 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
Previous Next

You Might Also Like

WordPress 7.0 Finally Fixes 20 Years of Painful Collaboration Problems
Solutions & Troubleshooting

WordPress 7.0 Finally Fixes 20 Years of Painful Collaboration Problems

Admin (Nghia Vo) Admin (Nghia Vo) March 9, 2026
HETZNER HOSTING
Solutions & Troubleshooting

Why Hetzner Might Not Be the Right Choice for Beginners

Admin (Nghia Vo) Admin (Nghia Vo) March 7, 2026
wordpress speed 2026
Solutions & Troubleshooting

WordPress Speed in 2026: The Only Hosting Checklist You Need

Admin (Nghia Vo) Admin (Nghia Vo) March 7, 2026
What Happens When Web Hosting Companies Get Acquired
Solutions & Troubleshooting

What Happens When Web Hosting Companies Get Acquired

Admin (Nghia Vo) Admin (Nghia Vo) March 6, 2026
wordpress shortcode 1
Solutions & Troubleshooting

WordPress Shortcodes: Complete Guide to Dynamic Content

Admin (Nghia Vo) Admin (Nghia Vo) March 4, 2026
How to Make Google Understand and Value Your Content
Solutions & Troubleshooting

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

Admin (Nghia Vo) Admin (Nghia Vo) June 5, 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
  • Editorial Standards
Welcome Back!

Sign in to your account

Lost your password?