Arch
Arch

Reputation: 527

Facebook Instant Articles for WP custom fields

I'm trying to include a custom field to the Facebook Instant Articles for WP plugin for Wordpress.

I'm on wordpress version 4.4.2 and php-5.6.18.

The custom field is a field for pasting youtube iframe code, for embedding in articles.

Can anyone provide a hint or an example of how to include this custom field in the generated output of the plugin?

Upvotes: 1

Views: 951

Answers (1)

Arch
Arch

Reputation: 527

Finally the solution was found in the plugin's support forum here

use Facebook\InstantArticles\Elements\Video;

add_action( 'instant_articles_after_transform_post', function ($ia_post) {
    $instant_article = $ia_post->instant_article;
    $post_id = $ia_post->get_the_id();
    $video_url = get_post_meta( $post_id, 'video_url', true );
    $instant_article->addChild( Video::create()->withURL($video_url) );
} );

Upvotes: 2

Related Questions