Get link to authors profile page in WordPress

You can have a profile page in the front end for every author where you have their bio, link to their website et cetera. But how to get a link to that page?

In my knowledge there is no preset function to do this. Structure for the URL is following example.com/author/author-name. We could try something like this:



' . get_the_author_meta('first_name') . ' ' . get_the_author_meta('last_name') . '' ?>

And the output for that would be:


John Smith

But, there is a small problem.

Usually login names are something like john or chris_bwoy_92, but in WordPress they can also be John Smith, i.e. have spaces in it, then the generated link will be something like: clubmate.fi/author/John%20Smith, the space is replaced with %20 and therefor the link will not work.

The better way

Simply, lowercase the username, and replace spaces with hyphens using, strtolower() and str_replace():



' . get_the_author_meta('first_name') . ' ' . get_the_author_meta('last_name') . '' ?>

Club-Mate, the beverage → club-mate.fi