Created
April 24, 2012 14:36
-
-
Save rupert-ong/2480147 to your computer and use it in GitHub Desktop.
Wordpress: "More From Author" to Feed
This file contains hidden or 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 | |
function authors_post_list_in_feed($content) { | |
if(is_feed()) { | |
global $post; | |
$author = get_the_author(); | |
$author_id = $post->post_author; | |
$the_posts = get_posts('author=' . $author_id . '&numberposts=5'); | |
$output = '<h3>More From ' . $author . '</h3>'; | |
$output .= '<ul>'; | |
foreach($the_posts as $post) { | |
$permalink = get_permalink(); | |
$title = get_the_title(); | |
$output .= '<li><a href="' . $permalink . '">' . $title . '</a></li>'; | |
} | |
wp_reset_query(); | |
$output .= '</ul>'; | |
$content = $content.$output; | |
} | |
return $content; | |
} | |
add_filter('the_content','authors_post_list_in_feed'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment