在 WordPress 中使用 JSON-LD 和 PHP 的文章丰富网页摘要
Article Rich Snippet with JSON-LD and PHP in WordPress
我正在尝试创建一个 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 属性中为徽标本身添加一个额外的内容。
只是想知道是否有人有任何想法?
尝试像这样在数组中嵌套数组:
$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
)
);
我正在尝试创建一个 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 属性中为徽标本身添加一个额外的内容。
只是想知道是否有人有任何想法?
尝试像这样在数组中嵌套数组:
$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
)
);