0

I'm using a recent theme which uses custom post formats for video, gallery, audio and more. In my RSS feed, these do not render properly. I mean the content is there but the video, gallery or audio attached to the post is not included in the RSS feed.

So you have a post that talks about this great new video, but no video or link is included in the RSS feed post content.

I would like to add a custom function to my theme custom-functions.php that will hook on the RSS feed generation and for these types of post formats add custom HTML so that they are included at the top of the post.

I'm pretty sure we can do something with the_content_rss hook and I'm guessing that for each post I can get the post format associated, but I can't find good examples.

Thanks for your help!

1 Answer 1

1

Write a small custom plugin wich a function, that enhance the default query for feeds.

The example below add all custom post types via get_post_types()to the default feed.

// add custom post type to wp post-feed
add_action( 'request', 'fb_add_to_feed' );

// add to post-feed
function fb_add_to_feed ( $request ) {

    if ( isset( $request['feed'] ) && ! isset( $request['post_type'] ) ) {
        $request['post_type'] = get_post_types ( $args = array (
            'public'          => TRUE,
            'capability_type' => 'post'
        ) );
    }

    return $request;
}

If you will control the custom post types inside the feed, then define the post types in the array of the code below.

// add custom post type to wp post-feed
add_action( 'request', 'fb_add_to_feed' );

// add to feed
function fb_add_to_feed ( $request ) {

    if ( isset( $request['feed'] ) && ! isset( $request['post_type'] ) ) {
        $request['post_type'] = array( 
            'post', 'stippet', 'archive', 'movies'
        );
    }

    return $request;
}
1
  • Thanks for this example, but I'm not sure I understand the purpose of this. Right now my feed already include all my custom post formats posts, but they just do not include the video/gallery/audio in the content. I would like to custom fetch what has been saved in the video/audio field and appropriately display it on the post content of the rss feed. Thanks!
    – Vallieres
    Commented Jun 20, 2013 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.