- Joined
- Oct 25, 2013
- Messages
- 752
- Reaction score
- 285
By tip, I mean removing the JSON-LD schema in Yoast so that when you add yours, you don't have two. I'm convinced that Google doesn't get confused when they see two markups (many sites have it) but still, it's easy to disable Yoast's schema, so you might as well.
Yoast has no UI button to get rid of schema, but they do have a hook in the API you can call. Go to the functions.php file in your theme, and add this line of code before the ?> at the end of the file.
EDIT: I previously had only part of the code needed, this is the updated, full code.
As always, if you aren't sure what you're doing, make sure you save a backup. Hosing one of the core theme files is never a good thing, and you can easily break your whole site temporarily just by having a ; in the wrong place.
To test it, refresh a page on your site, view source and do a ctr+f looking for "json", and you shouldn't see the Yoast schema anymore.
Fixing it this way will last even if you update the Yoast plugin, so do this instead of changing code in the actual plugin file.
Is this already common knowledge? Do you bother removing Yoast's schema when you add proper schema for a client? Did this work for you? Hope it helped!
Yoast has no UI button to get rid of schema, but they do have a hook in the API you can call. Go to the functions.php file in your theme, and add this line of code before the ?> at the end of the file.
EDIT: I previously had only part of the code needed, this is the updated, full code.
PHP:
function remove_json_ld_output( $data ) {
$data = array();
return $data;
}
add_filter('wpseo_json_ld_output', 'remove_json_ld_output', 10, 1);
As always, if you aren't sure what you're doing, make sure you save a backup. Hosing one of the core theme files is never a good thing, and you can easily break your whole site temporarily just by having a ; in the wrong place.
To test it, refresh a page on your site, view source and do a ctr+f looking for "json", and you shouldn't see the Yoast schema anymore.
Fixing it this way will last even if you update the Yoast plugin, so do this instead of changing code in the actual plugin file.
Is this already common knowledge? Do you bother removing Yoast's schema when you add proper schema for a client? Did this work for you? Hope it helped!
Last edited: