我需要在即时文章的内容中添加一些相关的帖子。 我使用这个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>
答案 0 :(得分: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"
}
}
}