Created
September 4, 2009 20:50
-
-
Save smajda/181121 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Appends a "View original at http://yourwpblog" link to end of post content | |
// in WordPress RSS feeds | |
function append_to_feed($postContent) { | |
global $post; | |
// append the link to the post content | |
$postContent .= '<p>(<a href="'.get_permalink().'">View original at '.get_bloginfo('url').'</a>)</p>'; | |
echo $postContent; | |
} | |
function run_append_filter() { | |
if (is_feed()) { | |
// you need both because the_content_rss isn't applied | |
// to rss2 & atom. Yes, this is a bug: | |
// http://trac.wordpress.org/ticket/3884 | |
add_filter('the_content', 'append_to_feed'); | |
add_filter('the_content_rss', 'append_to_feed'); | |
} | |
} | |
add_action('template_redirect', 'run_append_filter'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment