You mean like echo get_the_author_url()
?
wouldn’t that link to their website as specified in their profile?
anyway, since all author links are the same, it should be a fairly simple matter to construct the permalink based on the author’s display name if using pretty permalinks (or based on their ID maybe? if not… I dunno what the format is for ugly permalinks, but whatever it is, it’ll be similar for all authors).
I couldn’t find a function to return just the URL to an author’s posts.
Michael,
Like Ivovic said, that would echo the author’s url they set in their profile. Not quite what I’m after.
Using this href:
<a href="<?php bloginfo('url'); ?>/author/<?php the_author_nickname(); ?>"></a>
…around the author’s image does the trick of linking to their author profile. For SEO purposes, it’d probably be best if you/I make sure all the author nicknames are lowercase and contain no spaces, otherwise you’d see http://www.domain.com/author/Michael
Luckily, I don’t need to display the author’s nickname as text in my template, the avatar is all I need so I think this should do the trick.
Thanks for your quick replies guys.
to avoid having to set nicknames or keep track of your users, you can turn the above into:
<a href="<?php bloginfo('url'); ?>/author/<?php echo strtolower(get_the_author()); ?>"></a>
this makes sure that the link is valid, as the link relies on the display name as chosen, not the nickname field. The strtolower() part sends it to lowercase.
@ivovic
I’ve just tried your solution, and it seems to work.
But I have a question about it. On the site I’m working on, the author’s pages have a link that looks like this:
blogurl/author/john-smith
There are hyphens between the first and last names.
In the solution you posted, however, the link gets returned like this:
blogurl/author/john smith
with a space instead of a hypen, which gets interpreted by the browser like this:
blogurl/author/john%20smith
It pulls up the correct author url, but I’m just wondering if there are any problems with the fact that it’s not using the hyphens. Are hyphens and spaces considered the same in the url?
(*grumble* I’m also wondering why the hell WP has never introduced a template tag that simply returns the unlinkified author URL…)