Michael Grippi
Michael Grippi

Reputation: 213

Can I remove the JSON-LD schema that Yoast adds to my WordPress site?

I would like to remove the JSON-LD schema that Yoast applies to my WordPress site so that I can add my own. I have already added my own, and Google Structured Data Testing says that it is OK, but basically I have 3 separate JSON-LD schemas instead of two because of Yoast.

You can see what I mean here: https://search.google.com/structured-data/testing-tool/u/0/#url=http%3A%2F%2Fwww.yogabearpc.com

Yoast has added the WebSite schema and it seems unnecessary or even damaging?

Upvotes: 4

Views: 12889

Answers (5)

deepyes02
deepyes02

Reputation: 178

Disable all Yoast SEO's Schema output one liner:

add_filter( 'wpseo_json_ld_output', '__return_false' );

One of the answers above is right (i,e returning an empty array), however that is redundant work for simply disabling all Yoast SEO schemas.

Upvotes: 0

unor
unor

Reputation: 96717

Unless the data Yoast produces is wrong, there is no harm in having it. Quite the contrary, having more structured data is better than having less.

If having it is "unnecessary" depends on your definition of what is necessary. Some consumers might be interested in it, others not.

My guess is that Yoast adds a WebSite entity because of Google’s sitelinks searchbox rich snippet result, which allows Google users to search your site directly from the Google search result.

Upvotes: 0

michaelkrieger
michaelkrieger

Reputation: 129

If you want to disable just Organization or just Website, add this to your theme's functions.php file:

function bybe_remove_yoast_json($data){
    if ( (isset($data['@type'])) && ($data['@type'] == 'Organization') ) {
        $data = array();
    }
    return $data;
}
add_filter('wpseo_json_ld_output', 'bybe_remove_yoast_json', 10, 1);

Upvotes: 2

Raghavendra N
Raghavendra N

Reputation: 5496

Simplest way to completely disable the Yoast SEO schema JSON-LD

Add this line to functions.php file:

add_filter( 'wpseo_json_ld_output', '__return_empty_array' );

Source

Upvotes: 5

Simon Hayter
Simon Hayter

Reputation: 3171

I wanted to disable this because of the sitelinks searchbox and the fact that I don't have a search function that works globally, just on the blog. Having the search box enabled for me would have undesirable effects.

The easier option may just be to prevent Google using the sitelinks searchbox without having to touch the functions files. You can prevent Google using sitelinks searchbox on your site by using the following meta:

<meta name="google" content="nositelinkssearchbox" />

If you want to disable Yoast's JSON-LD all together then here's a snippet from my blog and the code I use on my site:

SOURCE

How to disable Yoast SEO Schema JSON-LD completely

function bybe_remove_yoast_json($data){
  $data = array();
  return $data;
}
add_filter('wpseo_json_ld_output', 'bybe_remove_yoast_json', 10, 1);

Login to your WordPress dashboard and head over to the editor within the tab menu appearance, find your functions file (normally named functions.php) and add the code below just before the PHP tag is closed at the bottom.

Upvotes: 9

Related Questions