WordPress: How to Add Custom Fields to RSS Feed

Last updated
App Shah
Crunchify » WordPress Optimization and Tutorials » WordPress: How to Add Custom Fields to RSS Feed


WordPress Custom Fields

Adding custom Fields to any WordPress Post is very powerful function, these fields allow you to store extra data about the post without it having to go into the content.

Sometime you have to put below kind of line at the end of each post in your RSS feed. I’m adding below information after each post on Crunchify’s feed.

WordPress Custom Field - Add text at the end of RSS field

But custom fields won’t appear in your RSS feed because this will only display your content, so you could miss important information for your RSS readers.

Other must read:

Here is a WordPress snippet to add to your functions.php file to display custom fields in your RSS feed.

get_the_ID() retrieve the ID of the current item in the WordPress Loop.

function crunchify_feed($content) {  
    if(is_feed()) {  
        $post_id = get_the_ID(); // sample reference. remove this if you don't want to use this
        $output = '<div><h3>Thanks for visiting..</h3>';  
        $output .= '<p>If you enjoyed this post - Follow me here..</p>';  
        $output .= '<p><strong>Facebook:</strong> <a href='http://facebook.com/Crunchify'>Follow</a></p>';  
        $output .= '<p><strong>Twitter:</strong> <a href='http://twitter.com/Crunchify'>Follow</a></p>';  
        $output .= '</div>';  
        $content = $content.$output;  
    return $content;  

7 thoughts on “WordPress: How to Add Custom Fields to RSS Feed”

    • That’s right Ramon. It’s optional field. Please feel free to remove it if you have no intention to use it in your code snippet.

  1. I tried to use this but it didnt displayed in my post like yours in single post.!! Help me fix this . I am using genesis

      • hey thanks, it worked i was just towards looking forwar for older post. Any idea how to display this in older post ? Will it work by republishing our old posts ?

          • Hey, last time it was working on my pc now its showing error like
            Parse error: syntax error, unexpected T_STRING in C:xampphtdocswordpresswp-contentthemeseleven40-profunctions.php on line 183

            I want to put same as you have at end of your post like
            If you enjoyed this post, make sure to subscribe to Crunchify’s RSS feed.

            Give me step from first what do i have to do..just putting the code in function.php is not working

Leave a Comment