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
    • 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

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

How I Optimized Pagination and Skyrocketed Traffic

How to Pick the Ideal Blogging Platform for Your Needs

Protecting Your WordPress Site from File Upload Vulnerabilities

Title and Meta Description Mismatch on Google[How to fix]

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 Stories

Battlefield 1 fix error First time launching 2
Gaming Errors & Solutions

Battlefield 1 fix error First time launching and can’t click “OK” on initial splash screen

September 23, 2024
How to Install WordPress on cPanel
Installation & Setup

How to Install WordPress on cPanel: A Beginner-Friendly Guide

April 24, 2025
Computer Tips

6 Tips to Boost Your Hard Drive Performance

July 28, 2023
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
How to Check Computer Power Supply
Computer Hardware

How to Check Computer Power Supply

July 29, 2023
How to Add a Read More to Product Descriptions in WooCommerce
Solutions & Troubleshooting

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

May 5, 2025

You Might Also Like

Contact button
Solutions & Troubleshooting

Contact button in the footer with added call button shake effect

September 21, 2024
Guide to Creating a Beautiful Promotion Notification Box for Your Website
Solutions & Troubleshooting

How to Create a Stunning Notification Box for Your Website

September 20, 2024
Create a Simple Incrementing Number Effect with HTML and JavaScript 2
Solutions & Troubleshooting

Create a Simple Incrementing Number Effect with HTML and JavaScript

September 17, 2024
Guide to Using Multiple Domains for One WordPress Website
Solutions & Troubleshooting

Guide to Using Multiple Domains for One WordPress Website

September 16, 2024
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?