WordPress.org

Ready to get started?Download WordPress

Forums

Unable to add_filter to the_content_rss (4 posts)

  1. phiali
    Member
    Posted 9 years ago #

    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!

  2. jcushman
    Member
    Posted 9 years ago #

    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
    }

  3. oodi
    Member
    Posted 8 years ago #

    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?

  4. twnyny
    Member
    Posted 8 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.