Title: Include custom fields in feed
Last modified: August 31, 2016

---

# Include custom fields in feed

 *  Resolved [xscv2314](https://wordpress.org/support/users/xscv2314/)
 * (@xscv2314)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/include-custom-fields-in-feed/)
 * How can one include custom fields in the feed? In particular I want to include
   a video frame from youtube that is being added to the article as a custom field.
 * [https://wordpress.org/plugins/fb-instant-articles/](https://wordpress.org/plugins/fb-instant-articles/)

Viewing 14 replies - 1 through 14 (of 14 total)

 *  Plugin Author [diegoquinteiro](https://wordpress.org/support/users/diegoquinteiro/)
 * (@diegoquinteiro)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/include-custom-fields-in-feed/#post-7261057)
 * You should be able to use the `instant_articles_after_transform_post` hook to
   manipulate the article after the basic transformation is made using the main 
   post body.
 * Something like:
 *     ```
       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) );
       } );
       ```
   
 * Does that work?
 *  Plugin Author [diegoquinteiro](https://wordpress.org/support/users/diegoquinteiro/)
 * (@diegoquinteiro)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/include-custom-fields-in-feed/#post-7261058)
 * Please refer to the Instant Articles SDK documentation:
 * [https://github.com/facebook/facebook-instant-articles-sdk-php/blob/master/docs/QuickStart.md](https://github.com/facebook/facebook-instant-articles-sdk-php/blob/master/docs/QuickStart.md)
 *  Thread Starter [xscv2314](https://wordpress.org/support/users/xscv2314/)
 * (@xscv2314)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/include-custom-fields-in-feed/#post-7261082)
 * Hi, thanks for the response, but I’m a bit confused. Isn’t this example from 
   a different plugin than the one I’m referring to?
 *  Plugin Author [diegoquinteiro](https://wordpress.org/support/users/diegoquinteiro/)
 * (@diegoquinteiro)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/include-custom-fields-in-feed/#post-7261085)
 * Hi,
 * No, that should be right. This is how you do it on v2.0+
 * There was a big rewrite of the plugin on this version.
 *  Thread Starter [xscv2314](https://wordpress.org/support/users/xscv2314/)
 * (@xscv2314)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/include-custom-fields-in-feed/#post-7261153)
 * Thanks a lot diegoquinteiro! I have to admit I was wrong, I updated the plugin
   and the above code worked perfectly.
    But, is there a way to add a child to the
   head of the children array? I tried to use the ‘instant_articles_before_transform_post’
   action but it didn’t worked. I’m just trying to place the video on top of the
   content if that is possible. I tried to change the children array but it is set
   as private.
 *  Thread Starter [xscv2314](https://wordpress.org/support/users/xscv2314/)
 * (@xscv2314)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/include-custom-fields-in-feed/#post-7261155)
 * Oh forgot, problem solved!
 *  [pr0fess0r](https://wordpress.org/support/users/pr0fess0r/)
 * (@pr0fess0r)
 * [9 years, 12 months ago](https://wordpress.org/support/topic/include-custom-fields-in-feed/#post-7261204)
 * How would you add a full YouTube Embed tag? Is there documentation for Video::
   create() that shows how this can be done? Or can you add it as a paragraph?
 * Cheers
 *  [pr0fess0r](https://wordpress.org/support/users/pr0fess0r/)
 * (@pr0fess0r)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/include-custom-fields-in-feed/#post-7261205)
 * Hey xscv2314 how did you add the video to the top of the content?
    Does a YouTube
   URL work or do you need a link to an .mp4 file?
 * Cheers
 *  [bgantick](https://wordpress.org/support/users/bgantick/)
 * (@bgantick)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/include-custom-fields-in-feed/#post-7261221)
 * Also wondering how one might use `addChild` to add nodes before `the_content`.
   xscv2314 – did you get it working?
 *  [jamestylerpatton](https://wordpress.org/support/users/jamestylerpatton/)
 * (@jamestylerpatton)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/include-custom-fields-in-feed/#post-7261225)
 * I was able to add the full Youtube tag with something like this using the SocialEmbed
   class instead.
 *     ```
       use Facebook\InstantArticles\Elements\SocialEmbed;
       add_action( 'instant_articles_after_transform_post', function ($ia_post) {
           $instant_article = $ia_post->instant_article;
           $post_id = $ia_post->get_the_id();
           $iframe_string = get_post_meta( $post_id, 'video_embed_code', true );
           preg_match('/src="([^"]+)"/', $iframe_string, $match);
           $video_url = $match[1];
           $instant_article->addChild( SocialEmbed::create()->withSource($video_url) );
       } );
       ```
   
 * However, I’m still trying to get the video to appear before the content.
 *  [jkoon](https://wordpress.org/support/users/jkoon/)
 * (@jkoon)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/include-custom-fields-in-feed/#post-7261232)
 * Thanks jamestylerpatton, let me know if you find a way to get the video above
   the content.
 *  [jamestylerpatton](https://wordpress.org/support/users/jamestylerpatton/)
 * (@jamestylerpatton)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/include-custom-fields-in-feed/#post-7261233)
 * jkoon
    I was able to place the video above the content, but I had to edit one
   of the plugin files to get it to work, so it’s only a temporary fix until I find
   a better way.
 * In the file, fb-instant-articles/class-instant-articles-post.php, I added:
    `
   do_action( 'instant_articles_before_article_content', $this );` on line 674, 
   right after `$document = apply_filters( 'instant_articles_parsed_document', $
   document );`.
 * Also, you have to specify the width and the height when adding the video, so 
   my full functions.php code to add the video is:
 *     ```
       use Facebook\InstantArticles\Elements\SocialEmbed;
   
       function incl_video($ia_post) {
       	$instant_article = $ia_post->instant_article;
       	$post_id = $ia_post->get_the_id();
       	$iframe_string = get_post_meta( $post_id, 'video_embed_code', true );
       	if($iframe_string){
       		preg_match('/src="([^"]+)"/', $iframe_string, $match);
       		$video_url = $match[1];
       		$instant_article->addChild( SocialEmbed::create()->withSource($video_url)->withWidth(640)->withHeight(390) );
       	}
       }
       add_action( 'instant_articles_before_article_content', 'incl_video' );
       ```
   
 *  [sasa1](https://wordpress.org/support/users/sasa1/)
 * (@sasa1)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/include-custom-fields-in-feed/#post-7261234)
 * hello all, i’m trying to achieve something similar, but when i place code like
 *     ```
       instant_article->addChild(Paragraph::create())
       ```
   
 * in functions.php, something breaks (ie: stuck loading indicator in the insant
   article metabox). – is functions.php the place where this code should go? and
   is there something more to this than adding
 *     ```
       use Facebook\InstantArticles\Elements\SocialEmbed
       ```
   
 * ?
 *  [AndreyUK](https://wordpress.org/support/users/andreyuk/)
 * (@andreyuk)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/include-custom-fields-in-feed/#post-8870507)
 * custom video field not display

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘Include custom fields in feed’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/fb-instant-articles_8fa0a4.svg)
 * [Instant Articles for WP](https://wordpress.org/plugins/fb-instant-articles/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/fb-instant-articles/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/fb-instant-articles/)
 * [Active Topics](https://wordpress.org/support/plugin/fb-instant-articles/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/fb-instant-articles/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/fb-instant-articles/reviews/)

## Tags

 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [FBIA](https://wordpress.org/support/topic-tag/fbia/)

 * 14 replies
 * 8 participants
 * Last reply from: [AndreyUK](https://wordpress.org/support/users/andreyuk/)
 * Last activity: [9 years, 2 months ago](https://wordpress.org/support/topic/include-custom-fields-in-feed/#post-8870507)
 * Status: resolved