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.
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:
- WordPress: How to Add NoFollow Attributes to all Links in a Specific Category
- I choose BitBucket over Github for my Pro WordPress Plugins. Why?
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; } add_filter('the_content','crunchify_feed');