Disable WordPress Author Pages

Author page is part of WordPress by default. Without manual change, author page URL exposes user login username. From SEO point of view, it may also create duplicated content. For blog website, author page is useful when there are multiple authors. For non-blog site, especially for site without no blog post, it is good idea to disable the access to author page.

To disable access to author page (author archive), simply add this code snippet to functions.php file:

// Disalbe access to author page
add_action('template_redirect', 'my_custom_disable_author_page');

function my_custom_disable_author_page() {
	global $wp_query;

	if ( is_author() ) {
		$wp_query->set_404();
		status_header(404);
		// Redirect to homepage
		// wp_redirect(get_option('home'));
	}
}
add_action( 'template_redirect', 'remove_author_pages_page' );

Or if you want the redirect to something more friendly, for example, to redirect visitor to homepage instead of 404 error page, comment out line 8, 9, uncomment line 11.