2

我需要在即时文章的内容中添加一些相关的帖子。我使用这个 WordPress 插件:

https://github.com/Automattic/facebook-instant-articles-wp

我的帖子有:

<ul class="related-article">
  <li>
     <a href="http://example.com/"></a>
  </li>
</ul>

我在我的变压器规则中添加了这个

{
      "class": "RelatedArticlesRule",
      "selector": ".related-article"

},
{
      "class": "RelatedItemRule",
      "selector": ".related-article li",
      "properties": {
        "related.url": {
          "type": "string",
          "selector": "a",
          "attribute": "href"
        }
      }
}

但在 trasformer 标记中,相关的 ul 不存在。我需要这样的东西:

<ul class="op-related-article">
  <li>
     <a href="http://example.com/"></a>
  </li>
</ul>
4

1 回答 1

0

看起来相关文章项目仅在内部检查,RelatedArticlesRule因此您的选择器错误。

这应该有效:

{
  "class": "RelatedArticlesRule",
  "selector": "ul.related-article",
  "properties" : {
    "related.title" : {
        "type" : "string",
        "selector" : "ul.related-article",
        "attribute": "title"
     }
  }
},
{
  "class": "RelatedItemRule",
  "selector": "li",
  "properties": {
    "related.url": {
      "type": "string",
      "selector": "a",
      "attribute": "href"
    }
  }
}
于 2016-12-14T09:31:23.003 回答