WordPress.org

Support

Support » Plugins and Hacks » Hacks » adding action hook to rss feed

adding action hook to rss feed

  • thewatcheruatu
    Member

    @thewatcheruatu

    I’m confused about something and I’m wondering if somebody can give me some insight. If I’m not mistaken, WordPress uses feed-rss2.php in the wp-includes folder to generate the RSS 2.0 feed. So I checked out that file and found this:

    <?php
    	/**
    	 * Fires at the end of each RSS2 feed item.
    	 *
    	 * @since 2.0.0
    	 */
    	do_action( 'rss2_item' );
    	?>

    So my understanding is that in my theme’s functions.php, I should be able to hook a function onto that like so:

    function myrss_function() {
    	echo '<mynodename>stuff</mynodename>';
    }
    
    add_action ('rss2_item', 'myrss_function');

    I’ve done that, however nothing at all changes at http://mysite.com/feed/

    So what I did was actually directly edit feed-rss2.php and hard code a dummy node in there, and still nothing changes when I view my site’s feed. So I don’t get it–is WP actually using something else to generate that feed output? I tried clearing my cache and using different browsers thinking it might have just been a caching issue, but it is the same result every time.

Viewing 1 replies (of 1 total)
  • thewatcheruatu
    Member

    @thewatcheruatu

    Okay, never mind. I guess the server session is actually caching the feed for the user or something. I’m not sure, honestly, what’s going on, but after leaving it alone for a sufficient time period, my browser fetched the newest version of the RSS feed with the node that I hooked in within functions.php.

Viewing 1 replies (of 1 total)
  • The topic ‘adding action hook to rss feed’ is closed to new replies.