in Wordpress

Add Custom Fields To RSS Feed

Wordpress has the ability to add custom fields to any post, these fields allow you to store extra data about the post without it having to go into the content. You can use this data to add an extra piece of information to expand on your post. For example if you were displaying products on your Wordpress site then you would use the content area to write the product description and use the custom fields for the product code, price and ratings. This way you can display this data the same way on each product page. 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. Here is a Wordpress snippet to add to your functions.php file to display custom fields in your RSS feed.

function fields_in_feed($content) {  
    if(is_feed()) {  
        $post_id = get_the_ID();  
        $output = '<div><h3>Find me on</h3>';  
        $output .= '<p><strong>Facebook:</strong> ' . get_post_meta($post_id, "facebook_url", true) . '</p>';  
        $output .= '<p><strong>Google:</strong> ' . get_post_meta($post_id, "google_url", true) . '</p>';  
        $output .= '<p><strong>Twitter:</strong> ' . get_post_meta($post_id, "twitter_url", true) . '</p>';  
        $output .= '</div>';  
        $content = $content.$output;  
    return $content;