Could you define “current author”? Is this supposed to be the last author who’s posted, or something else?
Sorry, I meant current author on an Author archive page.
for Example, I want to say something as simple as:
You’re currently viewing “Steve stevensons” page of posts:
With 1.5 you can create an author page template (author.php) and place it in the directory for your theme. An easy way to do this is duplicate the index.php for a theme and make whatever modifications you want. You can then include some PHP code to grab and display author details (outside The Loop):
<?php
if(isset($_GET['author_name'])) :
$curauth = get_userdatabylogin($author_name);
else :
$curauth = get_userdata($author);
endif;
?>
<h3>You're currently viewing <?php echo $curauth->user_firstname; ?> <?php echo $curauth->user_lastname; ?>'s page of posts:</h3>
Here’s all the author profile data you could access this way:
$curauth->user_aim;
$curauth->user_email;
$curauth->user_firstname;
$curauth->user_icq;
$curauth->user_lastname;
$curauth->user_level;
$curauth->user_login;
$curauth->user_msn;
$curauth->user_nickname;
$curauth->user_description;
$curauth->user_url;
$curauth->user_yim;
Thanks man – worked great!
worked for me too (haha)…thanks
i used this thanks, worked great!
I can’t get this solution to work?! This is how my author.php currently looks like:
—————————
<?php get_header(); ?>
<div id=”content”>
<?php
if(isset($_GET[‘author_name’])) :
$curauth = get_userdatabylogin($author_name);
else :
$curauth = get_userdata($author);
endif;
?>
<h3>You’re currently viewing <?php echo $curauth->user_firstname; ?> <?php echo $curauth->user_lastname; ?>’s page of posts:</h3>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
—————————-
I can’t even explain my problem. Have a look at the site:
http://zeitgeist.collectanea.org
zeitgeist-y: It’s possible the queried vars are not getting set, so try this:
<?php
if(isset($_GET['author_name'])) :
$curauth = get_userdatabylogin($_GET['author_name']);
else :
$curauth = get_userdata($_GET['author']);
endif;
?>
Or the purely 1.5 way:
<?php
if(get_query_var('author_name')) :
$curauth = get_userdatabylogin(get_query_var('author_name'));
else :
$curauth = get_userdata(get_query_var('author'));
endif;
?>
As a matter of interest – can this be done for version 1.22?
Thanks
The code blocks above other than the last one marked “purely 1.5” should work in 1.2.x, though you can’t create an author.php template to run it off (or rather you can, but WordPress won’t acknowledge it).
Thanls Kafkaesqui,
Where do I actually place that code?
Thanks
F
Where ever you want it displayed.
You can wrap the whole thing (script and anything it’s suppose to display) in an if statement that tests whether author_name
or author
have been passed as a query. This way it’s not displayed on other page types:
<?php if(isset($_GET['author_name']) || isset($_GET['author'])) :
if($_GET['author_name']) :
$curauth = get_userdatabylogin($_GET['author_name']);
else :
$curauth = get_userdata($_GET['author']);
endif;
?>
<h3>You're currently viewing <?php echo $curauth->user_firstname; ?> <?php echo $curauth->user_lastname; ?>'s page of posts:</h3>
<?php endif; ?>
Thanks for that but it didn’t show up any authors when I clicked on an author ling from ‘<?php wp_list_authors(‘optioncount=1&show_fullname=1&hide_empty=1′); ?>’
Not sure why though 🙂
Huh, here’s an odd question–when I use the tag in Fiona’s post directly above, I get all of the authors who have posted on my site except for one–me. The admin doesn’t show up. Is there a way to change this?
Sorry, I tried searching the codex, but I find it rather confusing. I mean, what’s the difference between the ‘go’ and the ‘search’ buttons, anyway?
@thepete
See the info on the ‘exclude_admin’ parameter for wp_list_authors()
:
http://codex.wordpress.org/Template_Tags/wp_list_authors