Disable Author pages in your WordPress installation

If you don’t need author post pages in WordPress disable the link and have them redirect back to the homepage. Add the below code to your themes child function.php file.

add_action('template_redirect', 'my_custom_disable_author_page');
 
function my_custom_disable_author_page() {
 global $wp_query;
 
  if( is_category() || is_tag() || is_date() || is_author() )  {
		 $wp_query->set_301();
		 status_header(301);
		 // Redirect to homepage
		 wp_redirect(get_option('home'));
	 }
}
add_action( 'template_redirect', 'remove_author_pages_page' );
Posted in