Remove WooCommerce Generated Product Schema

Remove WooCommerce Generated Product Schema
Remove WooCommerce Generated Product Schema

Learn how to remove WooCommerce's auto-generated product schema markup from your shop and product category pages with a simple code snippet. Optimize your site's structured data for better control over your SEO strategy.

WooCommerce automatically generates structured data for your products to help search engines better understand your website. This structured data, also known as schema markup, can improve the visibility of your products in search engine results by enabling rich snippets (such as pricing and ratings). However, not all website owners find the generated product schema markup necessary, especially if they are using custom SEO or schema tools. If you’d like to remove this WooCommerce-generated schema markup from the Shop and Product Category pages, follow the steps outlined in this tutorial.

Step 1: Open the functions.php file

The functions.php file is where you will add custom code to modify your theme’s behavior. To open it, log in to your WordPress Dashboard and go to Appearance > Theme Editor. This will take you to the Theme Editor page, where you will find a list of theme files on the right-hand side. Look for functions.php in this list and select it to open the file for editing. If you’re working on a child theme, make sure you are editing the child theme’s functions.php file to ensure future-proof changes.

Step 2: Add the Code

After opening the functions.php file, scroll to the bottom and paste the following code:

PHP
<?php
/**
 * Remove the generated product schema markup from the Product Category and Shop pages.
 */
function wc_remove_product_schema_product_archive() {
    // Remove the action that generates product data from the WooCommerce Shop page.
    remove_action( 'woocommerce_shop_loop', array( WC()->structured_data, 'generate_product_data' ), 10, 0 );
}
// Add the 'wc_remove_product_schema_product_archive' function to the 'woocommerce_init' action.
add_action( 'woocommerce_init', 'wc_remove_product_schema_product_archive' );
/**
 * Remove structured data output on all pages.
 */
function wc_remove_output_structured_data() {
    // Remove structured data output from the footer of all pages.
    remove_action( 'wp_footer', array( WC()->structured_data, 'output_structured_data' ), 10 );
    // Remove structured data output from the email order details section of WooCommerce emails.
    remove_action( 'woocommerce_email_order_details', array( WC()->structured_data, 'output_email_structured_data' ), 30 );
}
// Add the 'wc_remove_output_structured_data' function to the 'init' action.
add_action( 'init', 'wc_remove_output_structured_data' );

This code does two things:

  • The first function, wc_remove_product_schema_product_archive(), removes the action that generates product schema on the WooCommerce Shop and Product Category pages. This means that the product schema markup will no longer appear in those areas.
  • The second function, wc_remove_output_structured_data(), removes the structured data output from all pages and WooCommerce emails. It specifically targets the footer section of your site (where WooCommerce usually outputs structured data) and the email order details section of WooCommerce emails, ensuring schema markup is removed in these instances.

By removing these actions, you are preventing WooCommerce from generating the default product schema markup, giving you full control over how search engines interpret your product data, should you wish to use custom markup.

Step 3: Save the Changes

Once you’ve added the code, scroll down and click the Update File button to save your changes. This will ensure that the schema removal is applied to your website.

Step 4: Check Your Website

After saving the changes, visit your WooCommerce Shop and Product Category pages to confirm that the product schema markup has been removed. You can also check your WooCommerce email templates, especially if you were using structured data in emails, to ensure the removal is reflected there as well.

To confirm the changes, you can use tools like Google’s Rich Results Test or Schema Markup Validator to see if structured data is still being generated on your site.

Why You Might Want to Remove WooCommerce Product Schema Markup

While WooCommerce’s default product schema can be helpful for SEO, there are several reasons you might want to remove it:

  • Using a Custom Schema Plugin: If you’re using a plugin like Schema and Structured Data for WP or a custom-built solution to handle your schema, the default WooCommerce schema can conflict with your setup, leading to duplicate or incorrect schema data.
  • Not Targeting Product Rich Snippets: If your products are not listed for public sale or you’re not interested in search engines displaying product-specific rich snippets (like pricing and reviews), you may not need this structured data on your site.
  • Customization Needs: Sometimes, you need a more customized schema implementation, which the default WooCommerce output doesn’t provide. Removing the default schema gives you the freedom to create custom markup that fits your needs.
Conclusion

By following this tutorial, you have successfully removed WooCommerce’s auto-generated product schema markup from your Shop and Product Category pages. This process can be especially useful if you’re using custom schema markup for SEO or if the default schema is not needed for your website. Always remember to test your site thoroughly after making changes to ensure that everything is functioning as expected. With this modification, you have more control over how your site interacts with search engines and handles structured data.

Next: WooCommerce vs Shopify

Leave a Comment

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


Scroll to Top