Display recent posts by author
-
On my single post pages i want to dsiplay the last 5 posts by that particular post’s author. i have a code to display the last 10 posts in the same category, but i want one for that particular author. i do this for the categories using this code…
<?php if (is_single( )) { $post_ID = $wp_query->posts[0]->ID; $all_cats_of_post = get_the_category($post_ID); $first_cat_ID = $all_cats_of_post[0]->cat_ID; $first_cat_name = $all_cats_of_post[0]->cat_name; ?> <div id="category-posts-<?php echo $first_cat_ID; ?>" class="widget widget_recent_entries"> <div class="widget-title"><b>Last 10 posts in <?php echo $first_cat_name; ?>:</b></div> <div class="widget-content"> <table width=100%><tr><td width=1%></td><td> <?php global $post; $cat_posts = get_posts('numberposts=10&category='.$first_cat_ID); foreach($cat_posts as $post) : ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li><br /> <?php endforeach; ?> </div> </div> <?php } ?> </td></tr></table>
i have been trying to tinker with this but have been unsuccessful in getting this to show me the last posts by author instead of just category like in the code above. help would be greatly appreciated. thanks.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Display recent posts by author’ is closed to new replies.