WordPress.org

Support

Support » Plugins and Hacks » Unable to add_filter to the_content_rss

Unable to add_filter to the_content_rss

  • Hi there,

    I have the following code that should alter the content of the RSS feed but nothing happens in WordPress 1.2.1


    function rssFooterTitle($rssContent)
    {
    /**************************************************************************
    ** Replace this with the code you would to append onto RSS posts . **
    **************************************************************************/

    $rssFooter = "(Title) This was generated by RSSFoot @ http://www.0gravity.co.uk/";

    /* Append our text */
    $rssContent.= $rssFooter;

    return ($rssContent);
    }

    add_filter('the_content_rss', 'rssFooterContent');

    Any ideas with what might be wrong? the_excerpt_rss and the_title_rss work fine though!

Viewing 3 replies - 1 through 3 (of 3 total)
  • A couple months late, I know, but I ran into the same problem. As far as I can tell the_content_rss doesn’t actually exist for some reason, but you can work around this by adding a filter for ‘the_content’ with this at the top:

    function my_filter($content){
    global $doing_rss;
    if(!$doing_rss)
    return $content;

    //do your rss-only filtering here
    }

    I have this in a plugin:

    global $doing_rss;

    /* Check for RSS */
    if ($doing_rss) {
    return $content;
    }

    Whatever follows after is still applied to the content. Something broken?

    I’ve been having the exact same problem. The variable $doing_rss gets set to 1 by all the feed-related files, but nothing in WP ever seems to use it. It still should be available to plug-ins, but???

    I couldn’t get is_feed() to work either. This does though:

    `global $wp_query;

    if ($wp_query->is_feed)’

    The puzzle is why that works and is_feed(), which does the exact same thing, doesn’t. Surely you’re able to call WP functions from within plugins?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Unable to add_filter to the_content_rss’ is closed to new replies.
Skip to toolbar