The Template Tag, the_author() is intended to be used in The Loop.
See Author_Templates for more information on displaying the author in a given author archive.
Its strange that it does not work, because we had this working on another blog (different theme) with the exact code I provided above.
also isn’t the retrieval of all posts by an author considered a loop? May be not the main loop but it also cycles.
As MichaelH mentioned, I don’t think the_author() works unless you use it within a WordPress loop. Yes, the retrieval of all posts by an author is a loop, but unless you use the_author() within that coded loop, it won’t work.
I don’t think that second segment of code you posted is in a WordPress Loop. If it was, you’d get that display for every post listed. Which I’m sure is not what you want.
What I think you want is something at the top of the page that displays the author’s name (i.e. outside the Loop). If so, try using something like this before the loop in the template that controls your author display:
<?php
if(isset($_GET['author_name'])) :
$curauth = get_userdatabylogin($author_name);
else :
$curauth = get_userdata(intval($author));
endif;
?>
<?php $auth_ID = $curauth->ID; ?>
<div class="left_author">
<?php echo get_avatar($curauth->ID, '96' ); ?>
<h2>Author: <?php echo $curauth->nickname; ?></h2>
?>
[EDIT] – Don’t cut and paste this code, it’s got my own div names and is probably missing some closing tags. You’ll be able to use most of it, though.
thanks for your response I will give your code a try.
BTW, the second piece of code I posted is at the top of the index page with several other similar archive retrieval statements (by category, by year,by month,by day and by tag).
All work (including the retireval by author) on another blog. I am not sure why it does not work on this blog.
Not sure, you could use a pastebin to post the code for comparison and then link to it here. Myself or others could try taking a look.
Let us know if that works for you.
I pasted the code from the index.php file into http://wordpress.pastebin.com/m57f70450
let me know if you see anything π
I tested that code outside the loop in my author.php and got nothing. Maybe paste the code where you say it’s working?
Logically and per the codex, the_author() shouldn’t work unless you’re querying a post, so if you use it outside the Loop in an index.php, how does it know what author to display?
here is the one that works, its almost identical. We used it to construct the new blog.
http://wordpress.pastebin.com/m68792640
I just want to point out that the only difference between the version that is working and the one that is not is that original one displays the author’s name in a line above the retrieved posts, the other one does not.
Both versions retieve all posts by the author whose name is clicked on in the header line in one of the posts.
<h6><?php the_time('l, F jS, Y'); ?> &nbsp <?php the_time( ); ?> | Author: <?php the_author_posts_link();?> | <?php the_category(', '); ?>
| <?php comments_popup_link(__('No Comments'), __('1 Comment'), __('% Comments')); ?></h6>