Showing the Authors Other Recent Posts

In Twenty Ten, there's a footer in single.php that displays the author's Gravatar, bio, and a link to all their posts. You can enhance this to show a list of the author's most recent posts using the code shown in Listing 7-11. The results are shown in Figure 7-5.

Listing 7-11. Displaying the post author's five most recent other posts inside the Loop <?php

$original_query = $query_string;

query_posts( 'post_type=post&orderby=date&posts_per_page=5&exclude'.$post->ID.'&author='.$post->post_author );

if (have_posts()) : ?> <ul class="authorposts">

<li><a href="<?php the_permalink() ?>" rel="bookmark" title="'Permanent link to <?php the_title_attribute(); ?>">

<?php the_title(); ?></a></li> <?php endwhile; ?>

Figure 7-5. Listing the author's most recent posts in Twenty Ten

Was this article helpful?

0 0

Post a comment