I submitted my site to Google and now the author page is showing up in the search results.
http://www.domain.com/author/myusername
How do I prevent my and others author names from showing up in search results?
It would be best to disable completely the path “/author/” all together because it’s not a blog but a product site (it only has pages).
I did a search earlier and saw that there are plugins to do this but I’d rather not install a plugin (sometimes they are not updated) if there is another way but will if I have to.
I also searched through the source code of the pages and did not see any links to the author page.
The above answer is good, but if redirecting to home page, it should specify a 30Best Answertatus and exit after.
add_action('template_redirect', 'my_custom_disable_author_page');
function my_custom_disable_author_page() {
global $wp_query;
if ( is_author() ) {
// Redirect to homepage, set status to 301 permenant redirect.
// Function defaults to 302 temporary redirect.
wp_redirect(get_option('home'), 301);
exit;
}
}
wp_redirect() documentation https://developer.wordpress.org/reference/functions/wp_redirect/