WooCommerce 3 introduced a new format to structured product data called JSON/LD. Overall it’s a big improvement from WooCommerce 2.x. That said some of us may generate our own Schema Data with other plugins or custom code. So how do we turn off and disable the WooCommerce function?
Going through the templates and removing really isn’t an ideal solution here. Luckily there is a single function you can add to your child theme’s functions.php file that will disable this.
/* Remove the default WooCommerce 3 JSON/LD structured data */ function remove_output_structured_data() { remove_action( 'wp_footer', array( WC()->structured_data, 'output_structured_data' ), 10 ); // This removes structured data from all frontend pages remove_action( 'woocommerce_email_order_details', array( WC()->structured_data, 'output_email_structured_data' ), 30 ); // This removes structured data from all Emails sent by WooCommerce } add_action( 'init', 'remove_output_structured_data' );
I’ve added comments above, the first remove action is for frontend pages and the second is for emails. You can choose to use either one or both.
We have a Structured Data plugin in the works that will be released before the end of April that gives you more control over the Schema Data. Within this plugin we’ll include the option to disable not only the WooCommerce Schema Data, but also Yoast’s Schema Data. We’ll drop a link here once it’s approved and released!
This solution didn’t work for me. It doesn’t appear to turn woocommerce structured data off. I pasted the exact code into my child theme functions.php file. Is there something that I’m doing wrong? Thanks in advance.
Just checked it out and appears it’s not turned off as you mentioned and also being duplicated further down the page. Google looks at the first instance only. What version of WooCommerce?
its work
Hey Kyle! Please, where do I paste this code to deactivate the woo commerce schema? Can you guide me? Do I have to install my Childs theme and then paste this code??
Correct in the functions.php file of your child theme.
Can I add this theme to my parent theme itself instead of the child theme?
You could if you’re not running a child theme, yes in the functions.php file.
How to add schema.org custom structured data script for woo commerce products
thank you it is nice code for me
Hey it just removed from the base product page but, there is schema still in inner product pages
This removes the data after it’s generated. It would be more efficient to remove the hooks that create the markup as well. Here is a sample gist – https://gist.github.com/wpexplorer/75fcdebf41850fc5efbc7b464db4b27f