Typek – Blog

How to Remove the Product Description in WooCommerce Using PHP Snippet

WooCommerce is a popular WordPress plugin that helps you build an online store. If you want to customize your store to better suit your needs, you may need to remove certain elements like the product description. In this tutorial, we’ll show you how to remove the product description in WooCommerce using a PHP snippet.

To achieve this, we’ll be using the remove_action() function in WordPress, which allows us to unhook certain actions. In this case, we’ll unhook the action responsible for displaying the product description on the product page. The process is simple and straightforward, but it’s essential to follow the steps correctly to avoid causing any issues on your website.

Let’s get started!

Step 1: Access your theme’s functions.php file

The first thing you need to do is access your theme’s functions.php file. This file is where you can add custom PHP code to modify your theme’s functionality. There are two ways to access this file:

  1. Using the WordPress Theme Editor
  2. Using an FTP client

Using the WordPress Theme Editor

To access the functions.php file through the WordPress Theme Editor, follow these steps:

  1. Login to your WordPress admin dashboard.
  2. Go to Appearance > Theme Editor.
  3. In the right sidebar, under the Theme Files section, find and click on the functions.php file to open it in the editor.

Using an FTP client

If you prefer using an FTP client, follow these steps:

  1. Connect to your website’s server using your preferred FTP client.
  2. Navigate to the wp-content/themes directory.
  3. Find your active theme’s folder and open it.
  4. Locate the functions.php file and download it to your computer.
  5. Open the downloaded file using a code editor like Sublime Text or Visual Studio Code.

Step 2: Add the PHP snippet to remove the product description

Now that you have access to your theme’s functions.php file, you can add the PHP snippet that will remove the product description from your WooCommerce product pages. Add the following code at the end of your functions.php file:

<?php
// Remove the product description from WooCommerce product pages
function typek_remove_product_description() {
    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
}
add_action( 'init', 'typek_remove_product_description' );
?>

The code above defines a new function called typek_remove_product_description() that uses the remove_action() function to unhook the WooCommerce action responsible for displaying the product description. The action we want to remove is called woocommerce_single_product_summary, and the function that renders the description is woocommerce_template_single_excerpt. The priority of this action is 20.

After defining the function, we use the add_action() function to hook our typek_remove_product_description() function to the init action. This ensures that our function is called when WordPress initializes, effectively removing the product description from the product pages.

Step 3: Save and upload the modified functions.php file

Once you have added the PHP snippet to your functions.php file, you need to save the changes and upload the modified file back to your server.

If you used the WordPress Theme Editor:

Click the Update File button at the bottom of the editor to save your changes.

If you used an FTP client:

Save the changes in your code editor, then upload the modified functions.php file back to your theme’s folder on your server, overwriting the original file.

Step 4: Verify that the product description has been removed

Now that you have added the PHP snippet and saved the changes, it’s time to verify that the product description has been successfully removed from your WooCommerce product pages. To do this, follow these steps:

  1. Go to your website and navigate to a product page.
  2. Check the product summary section, where the product description used to be displayed.
  3. Confirm that the product description is no longer visible on the page.

If the product description is still visible, double-check that you followed the steps correctly and didn’t make any mistakes when adding the PHP snippet.

Conclusion

In this tutorial, we showed you how to remove the product description from WooCommerce product pages using a PHP snippet. By following these simple steps and adding the right code to your theme’s functions.php file, you can easily customize your WooCommerce store and remove any unwanted elements from the product pages.

Remember to always be cautious when modifying your theme’s files and make sure to create backups of your files before making any changes. This way, you can easily revert to the original files if something goes wrong.

More traffic??

Are you looking for effective solutions to increase your Google search visibility?

Contact us and discover the full potential of online sales.

What our clients are say?

For me, they are a happiness factory. They managed my store’s website in such a way that users became happy, after which it turned out that the search engine was also happy. When the search engine became happy and started bringing me more happy customers, my business became equally happy 🙂

Matt

Great company, I recommend it to everyone. Services of the highest standard. Very good customer approach. I am very satisfied with their work.

Lukasz Szajny

Complete professionalism and an incredible commitment to their work. It’s worth emphasizing their hassle-free communication and full availability. I definitely recommend them.

Alexander