I am trying to create a JSON-LD data block which uses PHP from WordPress to create rich snippets for Google and I've run into a little problem, for the publisher
property.
I need it in the following format (this is from Google):
"publisher": {
"@type": "Organization",
"name": "Example Publisher",
"logo": {
"@type": "ImageObject",
"url": "https://example.com/logo.jpg",
"width": 600,
"height": 60
}
},
Here is the code that I have so far:
$schema["Publisher"] = array(
"@type" => "Organization",
"name" => "Company Name",
"@type" => "ImageObject",
"url" => "logo url goes here", // Get Image URL
"height" => 159, // Height
"width" => 500, // Width
);
But this is not picking up correctly, I believe this is because I need to add an additional inside the Publisher attribute for the logo itself.
Just wondering if anyone had any ideas?
Try nesting array inside array like this:
$schema["Publisher"] = array(
"@type" => "Organization",
"name" => "Company Name",
"logo" => array(
"@type" => "ImageObject",
"url" => "logo url goes here", // Get Image URL
"height" => 159, // Height
"width" => 500, // Width
)
);