Coder Social home page Coder Social logo

haseemajaz / remove-product-description-hyperlinks-woocommerce Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 16 KB

This handy piece of code allows you to enhance the presentation of your WooCommerce product descriptions by removing hyperlinks, making your product pages cleaner and more user-friendly.

Home Page: https://haseemajaz.com

License: MIT License

hyperlink hyperlinks product product-description woocommerce woocommerce-api woocommerce-extension woocommerce-plugin woocommerce-products woocommerce-shop

remove-product-description-hyperlinks-woocommerce's Introduction

Remove-Product-Description-Hyperlinks-woocommerce

This handy piece of code allows you to enhance the presentation of your WooCommerce product descriptions by removing hyperlinks, making your product pages cleaner and more user-friendly.

What Does This Code Snippet Do?

When you're running an online store using WooCommerce, you might have product descriptions with hyperlinks that link to other pages or products. While hyperlinks are valuable in many contexts, sometimes they can clutter your product descriptions or distract potential customers. This is where the "Remove Product Description Hyperlinks" code snippet comes to the rescue. This simple WordPress code snippet is designed to be added to your theme's functions.php file. It targets product pages specifically. When added and activated, it scans the product description content and intelligently removes any hyperlinks, leaving behind only the clean, unlinked text. This helps to streamline your product pages, creating a more focused and aesthetically pleasing shopping experience for your customers.

How to Use This Code Snippet

If you want to integrate this functionality into your WooCommerce store, follow these simple steps:

Access the functions.php File:

Log in to your WordPress dashboard. Go to "Appearance" > "Theme Editor." Select your active theme. Add the Code Snippet:

On the right side, find and click on the functions.php file. Scroll to the bottom of the file and paste the following code snippet:

Code Snippet

function remove_product_description_hyperlinks($content) {
    if (is_product()) {
        // Remove hyperlinks from the product description
        $content = preg_replace('/<a(.*?)>(.*?)<\/a>/', '$2', $content);
    }
    return $content;
}
add_filter('the_content', 'remove_product_description_hyperlinks', 20);

Save Changes:

Click the "Update File" button to save your changes. Enjoy Clean Product Descriptions:

That's it! The code snippet is now active in your WooCommerce store. Visit any product page, and you'll notice that all hyperlinks within the product description have been gracefully removed, leaving only the plain text.

Customization You can further customize the behavior of this code snippet by modifying it to suit your specific needs. For instance, you can adjust the regular expression pattern in the code to handle different types of hyperlinks or modify the priority of the filter hook.

Contributions and Issues This open-source code snippet is hosted on GitHub to encourage collaboration and improvements from the community. If you have any ideas for enhancements or discover any issues, please feel free to open an issue on GitHub. We appreciate your involvement in making this code snippet even more useful.

License This "Remove Product Description Hyperlinks" code snippet is distributed under the GNU General Public License v2.0. It's free to use, modify, and distribute according to the terms of the license.

Thank you for considering this code snippet for your WooCommerce store. We hope it helps you create a cleaner and more engaging shopping experience for your customers. Happy selling!

remove-product-description-hyperlinks-woocommerce's People

Contributors

haseemajaz avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.