Skip to content

Instantly share code, notes, and snippets.

@rupert-ong
Created April 24, 2012 14:36
Show Gist options
  • Save rupert-ong/2480147 to your computer and use it in GitHub Desktop.
Save rupert-ong/2480147 to your computer and use it in GitHub Desktop.
Wordpress: "More From Author" to Feed
<?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