WordPress: Add footer text to feed posts

Here’s a small code snippet for adding text to the bottom of each post in your rss feed. This will not affect the post content shown on your site.

The below should be added to your themes function.php file.

/********************************************************************************
* Add Footer to RSS feed
*/

function mdr_postrss($content) {
    if(is_feed()){
        $site_name = get_bloginfo_rss('name');
        $post_title = get_the_title_rss();
        $home_url = home_url('/');
        $post_url = post_permalink();
        $content = $content.'<a href="'.$post_url.'">'.$post_title.'</a> is a post from: 
<a href="'.$home_url.'">'.$site_name.'</a> which is not allowed to be copied on other sites.';
    }
    return $content;
}
add_filter('the_excerpt_rss', 'mdr_postrss');
add_filter('the_content', 'mdr_postrss');

Or may be found on github.

Advertisements