I forgot to mention that I am using the Header and Footer Plugin and inserted the script for Google’s SiteLink Search Box at the bottom of every Page & Post and this script in the header of every page:
<script type="application/ld+json">
{
"@context": "http://schema.org/true",
"@type": "WebSite",
"url": "https://www.yoursite.com/",
"potentialAction": {
"@type": "SearchAction",
"target": "http://www.yoursite.com/search?q={search_term_string}",
"query-input":"required name=search_term_string"
}
}
</script>
My site is JohnSearles.com so you can see how the SDTT marks my site.
Yes, the SiteLinks Search Box Plugin is now part of Yoast’s WordPress-SEO and has the same error as the Yoast does.
Hi @jsearles
I am also facing the same problem with search box schema code. I fixed the error in code with your suggested code. But now I want to add this to my website. As you mentioned in your answer to add code
OK – I tried to comment out lines 217 through 242 and that shut down my site. So I reinstalled WordPress-SEO to put the class-json-ld.php back to it’s original status.
Then I added this code to my functions.php in my child theme
add_filter( ‘wpseo_json_ld_output’, ‘__return_false’ );
Success! No errors messages now.
I need your help to add code.
I am using eleven40 child theme and Genesis. But I unable to find the existing code for application/ld+json. Please can you help me where I can find and edit this code
Thank You
@jsidea – I am not a WordPress professional, just a person with a little coding experience who is trying to get my sites to report well in Google’s Webmaster Tools. GWT told me I didn’t have any Rich Snippets, so I’ve been working on that. Apparently it’s important to Google. Be sure that you are registered with GWT.
Here are some links for you;
Header-Footer Plugin
Google’s Structured Data Overview
JSON-LD Playground
A page with other GWT Tool Links (works if you have a site registered)
Here is the code for the Website and Search Term String
<script type="application/ld+json">
{
"@context": "http://schema.org/true",
"@type": "WebSite",
"url": "https://www.yoursite.com/",
"potentialAction": {
"@type": "SearchAction",
"target": "http://www.yoursite.com/search?q={search_term_string}",
"query-input":"required name=search_term_string"
}
}
</script>
Good luck. There are also plugins to add scripts to particular pages that could be useful for you.
@jsearles – Thanks for your help!
I find the isuue ! 🙂
You must go to plugins->editor -> WordPress SEO ->
find wordpress-seo/fronted/class-json-ld.php
And you must to add /true to schema.org
public function website() {
$this->data = array(
'@context' => 'http://schema.org',
'@type' => 'WebSite',
'url' => $this->get_home_url(),
'name' => $this->get_website_name(),
);
public function website() {
$this->data = array(
'@context' => 'http://schema.org/true',
'@type' => 'WebSite',
'url' => $this->get_home_url(),
'name' => $this->get_website_name(),
);
If doesn’t work
{search_term_string} must be the same in ‘query-input’ and in ?s=
$search_url = apply_filters( 'wpseo_json_ld_search_url', $this->get_home_url() . '?s={search_term_string}' );
$this->data['potentialAction'] = array(
'@type' => 'SearchAction',
'target' => $search_url,
'query-input' => 'required name=search_term_string',
);
}
}
Sorry if something was incomprehensible, becouse I’m from Poland
Thanka @mateuszx3 and everyone else who contributed to solve the issue. Your suggested fix (add /true to schema.org in wordpress-seo/fronted/class-json-ld.php) was successful!
@tacoverdo (Plugin Author). Pls consider this fix for the next plugin version, as else things will result in an error again.
Cheers
Thanks to all friends! I have fixed the code successfully now there is no error.
no problem 🙂 set solved
Thanks @mateuszx3
It worked for me too.
Hi, I’m trying to fix this error on the wordpress-seo/frontend/class-json-ld.php file, but it’s “inactive”. I have the plugin activated. It looks like all my frontend php files are inactive as well.
How do I activate this? It’s preventing me from updating the file. Thanks!
It’s no matter
When I do something in this file or another in editor it’s inactive too but work’ s it not try by ftp
thank you mateuszx3! That worked!
Hi @mateuszx3
Thanks for your input – unfortunately it hasn’t worked for my site! The structured data test is returning the same 2 errors for WebSite – just now it says http://schema.org/True
I checked the {search_term_string} also. Both ‘query-input’ and ‘?s=’ were listed as {search_term} so I changed this to {search_term_string} for both but still the error remains.
May I kindly ask if you know why please? My URL is http://juxtalegal.com
Thanks.
I’ve just looked into this a little more.
If I copy and paste the source code into the Structured Data Testing Tool, all is fine. However, if I fetch the URL the old source code shows. Is this just a case of Google still reading the old code and so will update next time Google crawls my site?
If so – Thank you @mateuszx3! Problem solved (I think).
If not work set only search_term and tell me what is your search engine it is from theme or from Google