UPDATED FOR YOAST 11.0+
As of the release of Yoast 11.0 on April 16th, 2019 you should use the below snippet to remove the Yoast Schema data:
add_filter( 'wpseo_json_ld_output', '__return_false' );
PRIOR TO YOAST 11.0
Yoast SEO is our favorite SEO plugin for WordPress. It helps you customize all of your search engine data at the page, post and site levels easily. One thing Yoast now includes is a generator for JSON-LD Schema Data. It generates it on the fly and inserts into your webpage. Schema Data is a great way to let search engines know what your page is about.
By default Yoast doesn’t include a setting to disable their Schema Data. They do an OK job constructing it but some of you may want to disable it completely if you’re using another plugin or method to generate it.
Open your functions.php file from your child theme and drop in this little snipped of code the the last line.
function disable_yoast_schema_data($data){ $data = array(); return $data; } add_filter('wpseo_json_ld_output', 'disable_yoast_schema_data', 10, 1);
Save the file and refresh you page, the Yoast Schema Data has been removed from your site.
If you’re running WooCommerce keep in mind it also generates Schema Data. We wrote an article on How to Remove the Woocommerce JSON/LD Structured Data Format.
Will this disable schema if implemented with GTM thereafter?
Hmm…not sure I follow your question, are you talking about Google Tag Manager?
You could test easily by add the code then viewing the source on your page and running a search for “schema.org”
GTM schema will not be disabled if you implement this. Go ahead Vasso 😀
1. I’m missing the AMP Publisher logo and getting an error on every post.
2. Running Yoast, Yoast Glue, and now a Schema plugin.
3. It seems I have two lots of JSON-LD one in the body – correct – and one in the footer – incorrect.
4. Google seems to be reading the last one unfortunately.
5. I have tried turning off Yoast, plus other plugins, but the JSON-LD in the footer persists.
6. Tried your code above, but it didn’t seem to work – I have a child theme.
7. I’m puzzled. Any ideas, please?
Sorry, I didn’t realise that Yoast and Yoast Glue both submit JSON-LD so I have turned Glue off and I think it works. Thanks so much!!!
Great, glad it helped!
This doesn’t seem to be disabling for me as the organization schema is still showing up when validating with the Schema tester. But I may have entered it wrong in my functions.php. Here’s how it looks:
<?php
function disable_yoast_schema_data($data){
$data = array();
return $data;
}
add_filter('wpseo_json_ld_output', 'disable_yoast_schema_data', 10, 1);
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
// BEGIN ENQUEUE PARENT ACTION
// AUTO GENERATED – Do not modify or remove comment markers above or below:
// END ENQUEUE PARENT ACTION
I’d bet it’s WordPress or WooCommerce doing this if you have it enabled as well. What’s your website URL?
http://www.theveritasfarms.com
We’re not using Woocommerce, so it’s either WP or Yoast.
Interesting, just took a look and it must be another plugin injecting this code or it’s defined in your template.
Have you checked the header template file to ensure this isn’t hard-coded?
it doesnt work, yoast structured data still appears
Please link me to your site, this code is still valid.
Ah as of April 16th 2019 they updated to Yoast 11.0 and the snippet no longer worked. Updated for version 11.0+ above and tested, working as expected now.
There is also a plugin to disable Yoast schema called Remove Schema. It can also remove schema markup from other plugins.
It’s possible to remove it from all pages or just from a specific page.
https://wordpress.org/plugins/remove-schema/
Hey Tim, nice find!
Looks like a relatively new plugin, but will help people for sure if it works correctly that don’t want to modify at the code level.
Have you taken a look to see if it is a light-weight plugin or bloated? Just curious if it slows down page loads with a lot of extra code or if it’s nice and light-weight.
thanks it’s work nice
Amazing, it works very well
How to remove schema on single page only?
Hi,
It doesn’t work for the website of my client. I added
add_filter( ‘wpseo_json_ld_output’, ‘__return_false’ );
in the functions.php of the theme at the bottom. But in the Google Structured Data Testing tool I still see Yoast..
https://www.barbara-psychicmedium.com/
Can someone please help? I don’t understand why it’s not working.
thanks its work well.
Tried the GTM to stop yoast structure data but it didn’t worked. At the end I installed snip it’s working.
Hi,
How can I understand that the code is working or not? Can you please explain? I have already added the code but couldn’t understand, it’s working or not.
I tried the code in WP-Config which created an error, then I tried it in functions.php but that did not do anything. Schema in Yoast is still visible. Is there a specific place we need this first code in?
add_filter( ‘wpseo_json_ld_output’, ‘__return_false’ );
thanks alot for this 🙂