In your single.php
Put this in your loop:
<?php
$author_id=$post->post_author;
?>
Then this after your loop:
<?php
$args=array(
'showposts' => 3,
'author' => $author_id,
'caller_get_posts'=>1
);
$posts=get_posts($args);
if ($posts) {
$curuser = get_userdata($author_id);
$author_post_url=get_author_posts_url($curuser->ID, $curuser->nicename);
echo 'User nicename: '.$curuser->user_nicename .', display Name: '. $curuser->display_name . ', link to author posts <a href="' . $author_post_url . '" title="' . sprintf( __( "Posts by %s" ), $curuser->user_nicename ) . '" ' . '>' . $curuser->user_nicename .'</a></p>';
foreach($posts as $post) {
setup_postdata($post); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
} // foreach($posts
} // if ($posts
?>
Thank you, that worked perfectly on single.php.
When I tried using it on other post templates (via this plugin: http://wordpress.org/extend/plugins/templates-for-posts/), it doesnt’ show the nicename, display name, or link to author posts, and it shows three links to the current post instead of three other posts by the current post’s author.
Any idea why this would be the case?
Thank you.
Guess you’d might have to assign the correct value to the $author_id variable I had placed in the loop.
I’m not sure I follow, sorry. Do you mean manually assign the value? I’m working on a multi-author blog so that wouldn’t be an ideal solution.
Not manually, but you may need to determine what variable does hold the post author ID and assign it to the $author_id variable.
Do you mean this?
‘<?php
$author_id=$post->[something other than post_author];
?>’
Sorry, not the coding-est guy around. Thanks.
If it is a ‘standard’ loop, then $post->post_author should work but depends on what is holding your posts.
it could be:
$author_id=$somethingelse->post_author
Cool. Thanks again for your help.