WordPress – How to change the author base in URLs

January 22, 2014

WordPress authors are given the default name and URL in the format: domain.com/author/author-name/. That’s great, but it may not always suit the type of site you have.

For example if you had an estate agency and wanted to link all posts from specific agents it wouldn’t quite look right.

Below is a simple function you can add to your site in the functions.php file or wherever to change the base of your authors to something else.

if ( ! function_exists( 'change_author_base' ) ) {
	function change_author_base() {
		global $wp_rewrite;
		$wp_rewrite->author_base = 'agent';
		$wp_rewrite->author_structure = '/' . $wp_rewrite->author_base. '/%author%';
	}
}
add_action('init','change_author_base');

In the example I have changed it to ‘agents’ and this will cause the new URL on the site to follow the format: domain.com/agent/agent-name/.