Yes the codex is great i agree, but unfortunately it does not answer the question being asked.
Steve, you’ll need to work out which file currently displays the unwanted heading and add an additional conditional statement..
For example let’s say you have a few lines like this (example only, obviously yours will differ)..
<?php if( is_archive() ) : ?> <!-- archive heading HTML --> <?php elseif( is_category() ) : ?> <!-- category heading HTML --> ... and so on..
You’d then just add another condition like so..
<?php if( is_archive() ) : ?> <!-- archive heading HTML --> <?php elseif( is_category() ) : ?> <!-- category heading HTML --> <?php elseif( is_author() ) : ?> <!-- your new author heading HTML here --> ...etc..
If that’s a little too much for you to follow, post the code from the file that currently deals with the heading and i’ll help you do it… 😉
If posting code, please use a pastebin… 🙂
Thanks for the reply.
The code is at http://wordpress.pastebin.com/p4ed6CjN
(or should I send it to you in another format?)
What I’d like to do is change the header on the author archive page. Now it reads “Author Archive.” I’d like it to read something like “Archive for [author’s name]”. Thanks for the help.
Is the author name shown in the URL when displaying an author page on your site?
If so, try updating this line..
<h2 class="pagetitle">Author Archive</h2>
<h2 class="pagetitle">Archive for <?php echo get_query_var('author_name'); ?></h2>
If not, i’ll have to come up with something else for you.. 🙂
No, unfortunately, the URL for the author archive page just ends with the number ID for the user, e.g., /?author=2. (I could try getting the author name into the URL using permalink, but I’m not sure how to structure the permalink so it works the way you’ve set this up.) Thanks for following up on this.
Ok, switch that for..
<?php if(get_query_var('author_name')) : $curauth = get_user_by('slug', get_query_var('author_name')); else : $curauth = get_userdata(get_query_var('author')); endif; ?> <h2 class="pagetitle">Archive for <?php echo $curauth->nickname; ?></h2>
Will support both author name and author id queries.
As seen in the example on the author template codex page.
Hope that helps.. 😉
That worked perfectly. Very impressive. Thanks a bunch, really.
- The topic ‘Author's name on archive page’ is closed to new replies.