I started using Instant Articles for WP plugin, but i am facing issue with related posts/article which are not showing in generated instant article. So, how to add related articles to Facebook Instant Article automatically?
Exactly, Instant Articles for WP plugin have a pre-defined transformer rules which aims to cover standard WordPress installations. Unfortunately, related articles rule not (yet) included into the pre-defined transformer rules. Also Facebook developer documentation wrote: You can include links to related articles in the ‘More from’ footer section and in-line in an article. You can control which links are included in the ‘More from’ section at the end of your articles. You can read more information about this at here
The problem is, how we do that automatically?. How to add related articles to Facebook Instant Article automatically?. Ok, let’s try to use the facilities that have been provided by Instant Articles for WP plugin. This great plugin have an ability to make custom transformer rules via Facebook Instant Articles settings which will be executed when importing posts from WordPress as Facebook Instant Articles
How to Make a Custom Transformer Rules?
The next problem before we can solve the real problem how to add related articles to Facebook Instant Article automatically? is: how to make a right custom transformer rules to generate related article?. So how to write these rules?. You may read some Facebook Instant Article documentation on rules or here to understand that
After reading and studying some documents on how to make custom transformer rules and how to add related articles to Facebook Instant Article, finally I decided to try to implement it. Here is my custom transformer rules to add related articles to Facebook Instant Article automatically
{ "rules" : [ { "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" } } } ]}
Discussion about this post