I'm trying to implement JSON-LD markup on my current WordPress project and ran into what I understand is a fairly common problem: SDTT responds with a "URL must point to the same page" error.
Following the recommendations from this page, I modified my code but the error still pops-up.
$mup = '{'."\n";
$mup .= ' "@type":"ListItem",'."\n";
$mup .= ' "position":'. ($i-1) .','."\n";
$mup .= ' "item": {'."\n";
$mup .= ' "@type" : "Report",'."\n";
$mup .= ' "author":"'. get_bloginfo('name') .'",'."\n";
$mup .= ' "publisher":{'."\n";
$mup .= ' "@type": "Organization",'."\n";
$mup .= ' "name": "'. get_bloginfo('name') .'",'."\n";
$mup .= ' "logo": "'. $image[0]. '"'."\n";
$mup .= ' },'."\n";
$mup .= ' "datePublished": "'. get_the_date("Y-m-d") .'",'."\n";
$mup .= ' "headline" : "'. get_the_title() .'",'."\n";
$mup .= ' "description" : "'.get_the_excerpt().'",'."\n";
$mup .= ' "genre" : "Case study",'."\n";
$mup .= ' "url":"'. get_permalink() .'"'."\n";
$mup .= ' }'."\n";
$mup .= ' }';
$markup[] = $mup;
And in the footer:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "ItemList",
"itemListElement": [<?php echo (join(",\n", $markup))."\n" ?>]
}
</script>
Example of generated code:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "ItemList",
"itemListElement": [{
"@type":"ListItem",
"position":1,
"item": {
"@type" : "Report",
"author":"RPA導入コンサルティング会社・RPAツール・RPAソフトを徹底比較",
"publisher":{
"@type": "Organization",
"name": "RPA導入コンサルティング会社・RPAツール・RPAソフトを徹底比較",
"logo": "http://rpa-media.net/wp-content/uploads/2018/04/logo.png"
},
"datePublished": "2018-04-04",
"headline" : "事例1",
"description" : "",
"genre" : "Case Study",
"url":"http://rpa-media.net/case-study/%e4%ba%8b%e4%be%8b%ef%bc%91/"
}
}
]
}
</script>
And beautified code:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "ItemList",
"itemListElement": [{
"@type": "ListItem",
"position": 1,
"item": {
"@type": "Report",
"author": "RPA導入コンサルティング会社・RPAツール・RPAソフトを徹底比較",
"publisher": {
"@type": "Organization",
"name": "RPA導入コンサルティング会社・RPAツール・RPAソフトを徹底比較",
"logo": "http://rpa-media.net/wp-content/uploads/2018/04/logo.png"
},
"datePublished": "2018-04-04",
"headline": "事例1",
"description": "",
"genre": "Case Study",
"url": "http://rpa-media.net/case-study/%e4%ba%8b%e4%be%8b%ef%bc%91/"
}
}]
}
</script>
This code generates the error BUT, if I take the generated code, beautify it in Atom then use it in SDTT, the error disappears.
If I try to use the beautified generated code directly on the page (as is, no PHP), the error comes back.
Any way I could implement that properly? Is my data badly structured? Or is it the way I am outputting it?