我正在尝试创建一个JSON-LD数据块,它使用WordPress中的PHP为Google创建丰富的代码段,我遇到了publisher
属性的一个小问题。
我需要采用以下格式(来自Google):
"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属性中添加一个额外的内容。
只是想知道是否有人有任何想法?
答案 0 :(得分:1)
尝试在数组中嵌套数组,如下所示:
$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
)
);