Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I need to add some code to my RSS feeds, so I am searching for the RSS Feed .php file so I can add my code. Any help in finding this template file would be greatly appreciated.

share|improve this question
add comment

3 Answers

To add some tags to the rss2 feed you may use the 3 action hooks that can be found in the wp-includes/feed-rss2.php

rss2_ns : to add a specific namespace

rss2_head : to add tags in the feed header

rss2_item : to add tags in each feed items

For example, let's assume you want to add a copyright in your feed's header using the dublin core vocabulary :

function my_rss2_head(){
    echo '<dc:rights>&copy; '.bloginfo_rss('name').'</dc:rights>'.PHP_EOL;
}
add_action( 'rss2_head', 'my_rss2_head');
share|improve this answer
add comment

Feed templates are in wp-includes folder, files starting with feed-. As rest of the WordPress core they are not supposed to be modified.

You will need to:

  1. Determine type of feed you want to modify (usually default RSS 2.0 one).
  2. Unhook native function that loads feed template, for example remove_action('do_feed_rss2','do_feed_rss2');
  3. Create your own feed template.
  4. Create and hook your own function that will load your template, by analogue with do_feed_rss2() ( source ).

Alternatively you can use some specific hooks in feed template to add what you want.

Update

As per Otto's comment steps 2 and 4 can be simplified using add_feed() function ( source ).

share|improve this answer
2  
A fine answer, but I'd recommend using the add_feed function instead. You can use it to replace a feed as well as add new ones. –  Otto Feb 3 '11 at 8:02
    
@Otto thanks for hint, looked at source and that would be much less cluttered to use indeed –  Rarst Feb 3 '11 at 8:18
add comment

Here's a quick guide: http://codex.wordpress.org/Customizing_Feeds

share|improve this answer
    
Some of the stuff in that article is verrrry old (as per warnings). I'd not rely on it without double checking with other materials and/or source code. –  Rarst Feb 2 '11 at 20:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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