我正在尝试创建一个JSON-LD数据块,该数据块使用WordPress中的PHP为Google创建丰富的摘要,对于publisher
属性,我遇到了一个小问题。
我需要以下格式(来自谷歌):
"publisher": {
"@type": "Organization",
"name": "Example Publisher",
"logo": {
"@type": "ImageObject",
"url": "https://example.com/logo.jpg",
"width": 600,
"height": 60
}
},
这是我到目前为止的代码:
$schema["Publisher"] = array(
"@type" => "Organization",
"name" => "Company Name",
"@type" => "ImageObject",
"url" => "logo url goes here", // Get Image URL
"height" => 159, // Height
"width" => 500, // Width
);
但这没有正确拾取,我相信这是因为我需要在徽标本身的 Publisher 属性中添加一个额外的内容。
只是想知道是否有人有任何想法?
尝试在数组中嵌套数组,如下所示:
$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
)
);