custom transformer rules
-
Hello,
I am having trouble following the documentation and creating custom instant article rules. Part of the confusion is because of the disconnect between FB documentation and the Plugin’s documentation. Your recent updates to the documentation are really helpful, but there are still a few things I am unclear about.
In FB documentation (https://developers.facebook.com/docs/instant-articles/sdk/transformer), it shows how to create a custom rule:
class MyCustomRule extends Rule { public function matchesContext($context) {} public function matchesNode($node) {} public function apply($transformer, $container, $node) {} }
But is the plugin already creating this for us or do I need to add this code to my functions.php file? For instance, I need to add in a rule for SimplePullQuote, I tried adding the following to the custom rules in the plugin interface:
{ "rules": [{ "class": "PullQuoteRule", "selector" : "div.simplePullQuote" }, { "class": "AddtoAnyRule", "selector" : "div.addtoany_share_save_container" }, { "class": "AddtoAnyRule", "selector" : "div.addtoany_content_bottom" }, { "class": "ImageRule", "selector" : "div.single-image" }, { "class": "SuperscriptRule", "selector" : "sup" //<sup> } ] }
But when I save and then go to a post, the FB IA interface cannot load the scripts and the activity indicator just infinitely scrolls. I am guessing this is because there is no e.g., “PullQuoteRule” class? So then would I need to add this to functions.php in my WP theme?
class MyCustomRule extends Rule { public function PullQuoteRule($context) {} }
I know some of this extends to the FB documentation, but I am finding it really confusing. I have tried to follow other threads, but none of them lead me to an answer that works. Really hoping for some help here.
Thank you in advance,
Donna
- The topic ‘custom transformer rules’ is closed to new replies.