Change Author Base URL in WordPress Permalinks

August 26th, 2014 - Posted by Steve Marks to PHP, Web Development.

By default when viewing a user’s profile page on the front end of a WordPress site, the URL will looks something like so:

http://mysite.com/author/joe-bloggs

The base URL will be ‘author’ followed by the users name. This is fine and works if users in the system are authors and post news articles etc.

In a site I was recently working on, ‘Users’ had a different meaning in that they are members that register and create a public profile. As a result, the term ‘author’ wasn’t quite right so I wanted to change the permalinks to reflect this.

The Solution

Fortunately the solution is a simple one and involved the following steps:

1. Add the following to the theme’s functions.php file:

add_action('init','change_author_permalinks');
function change_author_permalinks()
{
    global $wp_rewrite;
    $wp_rewrite->author_base = 'member'; // Change 'member' to be the base URL you wish to use
    $wp_rewrite->author_structure = '/' . $wp_rewrite->author_base. '/%author%';
}

2. Within WordPress navigate to ‘Settings > Permalinks‘ and just save the page without making any changes. This will force WordPress to flush the rewrite rules.

Now when someone views this user on the front end their profile URL will be like so:

http://mysite.com/member/joe-bloggs

Note: You should still use the author.php template to style the page. This won’t change to member.php, or whatever you set the base URL as.

Tags: ,
This entry was posted on Tuesday, August 26th, 2014 at 10:21 am by +Steve Marks and is filed under PHP, Web Development. You can follow any responses to this entry through the RSS 2.0 feed.
Comments...

Fear not, we won't publish this

Comments (1)
  1. Hayro.la says:

    very usefull info for me. thanks a lot :)