繁体   English   中英

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
    )
);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM