Support » Fixing WordPress » Author page not working when username has space
4 years, 11 months ago
I am trying to create author pages in my wordpress website. It seemed to work fine untill i tried a user with a space in his username…
A couple of users work fine except the two users with a space in the username so i guess that’s the problem. In my browser it tries to access: http://mywebsite.eu/author/part1%20part2
I get my 404 error page.
By the way, the part1 and part2 are the first and last name of the user. If possible i would like to see the nickname there..
I am using the following on the author page template:
$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
The link to the page i use is:
<?php the_author_posts_link(); ?>
Any ideas on this?
I was able to fix this by using the following url for the author pages:
<a href="<?php echo home_url() . '/author/' . get_the_author_meta( 'user_nicename', wp_get_current_user()->ID ); ?>
the user_nicename did the trick 🙂