Forums

How to exclude [caption] from rss feed? (6 posts)

  1. slamstar
    Member
    Posted 3 years ago #

    Hi there. Need your help.

    How can I exclude [caption] images from my rss feed?

  2. ernestortiz
    Member
    Posted 3 years ago #

    I had today the same problem and found this solution: "Idea: improving the_content_rss() in treating [caption] tag".

  3. ernestortiz
    Member
    Posted 3 years ago #

    I made it without to change the wordpress core: you must to use the same previous idea but with the help of a filter (in this case, a hook that WordPress launches to 'filter' the_content_rss).

    You just need to add the following code to the functions.php of your WordPress theme:

    function notags_content_rss($content='')
    {
    $content = preg_replace("/\[caption.*\[\/caption\]/", '',$content);
    $content = preg_replace("/\[googlevideo.*\[\/googlevideo\]/", '',$content);
    	return $content;
    }
    add_filter('the_content_rss', 'notags_content_rss');

    Here you can add as many tags to clean as you want.
    Hope it can be helpfull.

  4. Fips
    Member
    Posted 2 years ago #

    Brilliant, thanks very much ernestortiz, exactly what I've been looking for! :-)

  5. Blutarsky
    Member
    Posted 2 years ago #

    Guys I'm trying to modify the content of my feed.
    Would like to truncate, format & trim the body of each post appearing in the feeds.

    I have done the following, in functions.php in my theme folder:

    function RSS_headlines($content) {
        $content = my_trim_function($content);
        return $content;
    }
    add_filter('the_content_rss','RSS_headlines');

    But nothing changes, why is that?

  6. Blutarsky
    Member
    Posted 2 years ago #

    I have tested the code either in a plugin or in functions.php... seems there's no call to "the_content_rss" neither "the_content" (tried both).
    What I'm doing wrong?

Topic Closed

This topic has been closed to new replies.

About this Topic