get_query_var() gets its values from the URL that was used to create the query. Check out the function get_the_author().
Thanks for the reply. Unfortunately, that leaves the name missing.
Shows hosted by <?php $author = get_the_author(); ?>:
Show hosted by :
I’m not sure if this is the issue, but maybe worth a try: put back your original line of code, go into Users > and select a user. For each user there should be a drop-down menu where you can select how you want the name to be displayed on the public side – there should be a few options. Let me know if this helps.
I appreciate you trying but it didn’t change anything. I believe vtxyzzy was right. It’s pulling the name from the URL (domain.com/author/USER-NAME/).
But every other string of script I’ve tried causes the name to go missing altogether.
No worries. I should have checked some actual code first. 😉
This is what I use to display the author’s name:
<?php the_author(); ?>
…in conjunction with selecting from each user’s drop-down the desired name format. Let me know if it works.
I just figured it out.
I can use this:
<?php echo $curauth->nickname; ?>
So long as I changed some above script to this:
<?php $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author')); ?>
Thanks for your help.
Glad you found a solution. If you would please mark this thread as “resolved” it would be appreciated. Helps everyone keep better track of whose issues are still outstanding. Thanks!
OK, the_author() is only good when processing posts in the Loop. It gets the author of the current post. If you are not viewing posts, you have to use a different approach. See the Codex on Custom Author Information for some alternatives.
EDIT: OOPS – you beat me to it.
- The topic ‘Problem with displaying author_name’ is closed to new replies.