Remove /author/ from the author profile url

I’m trying to figure out the best way to remove /author/ from the profile URL of my users. I tried using the method in the link below and although it worked, it also prevented me from accessing any of my other pages that used a page template. So not sure if there’s a tweak I need to make to the code?

I would like to do this through the functions file and not use a plugin so any guidance is much appreciated.

add_action('init', 'cng_author_base');
function cng_author_base() {
   global $wp_rewrite;
   $author_slug = ''; // change slug name
   $wp_rewrite->author_base = $author_slug;
}

1 Answer
1

Essentially, you can’t do that because you’ve overlapped the “page” and “author” sections in the namespace.

See, with your setup, then given a URL like http://example.com/whatever, WordPress has no way to distinguish whether “whatever” is an author or a Page.

To do this, you’d need to add a lot more code to add extra querying during the rewrite parsing, basically. Which means that you should use a plugin to do it, if you still want to do it at all.

Leave a Comment