Remove WooCommerce Generated Product Schema

Remove WooCommerce Generated Product Schema

WooCommerce automatically generates structured data for your products to help search engines better understand your website. However, not all website owners find the generated product schema markup useful or necessary for their website. If you would like to remove the generated product schema markup from WooCommerce’s Shop and Product Category pages, follow these steps:

Step 1: Open the functions.php file

The functions.php file is located in your WordPress theme folder. To open it, go to your WordPress Dashboard, select Appearance, then select Theme Editor. This will bring up the Theme Editor page. On the right-hand side, you should see a list of files in your theme folder. Select the functions.php file.

Step 2: Add the Code

Copy the following code and paste it at the bottom of the functions.php file:

/**
 * 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 removes the structured data that WooCommerce generates for products on the Shop and Product Category pages. The first function, wc_remove_product_schema_product_archive(), removes the action that generates product data from the WooCommerce Shop page. The second function, wc_remove_output_structured_data(), removes the structured data output from the footer of all pages and the email order details section of WooCommerce emails.

Step 3: Save the Changes

Once you’ve added the code, save the changes to the functions.php file. You can do this by clicking the Update File button at the bottom of the screen.

Step 4: Check Your Website

Visit your website’s Shop and Product Category pages to ensure that the generated product schema markup has been removed.


Stay in the loop with our web development newsletter - no spam, just juicy updates! Join us now. Join our web development newsletter to stay updated on the latest industry news, trends, and tips. No spam, just juicy updates delivered straight to your inbox. Don't miss out - sign up now!


We’ve tried our best to explain everything thoroughly, even though there’s so much information out there. If you found our writing helpful, we’d really appreciate it if you could buy us a coffee as a token of support.

Also, if you’re interested in learning more about WordPress, Javascript, HTML, CSS, and programming in general, you can subscribe to our MailChimp for some extra insights.

Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.