I am not a fan of the Author Pages in WordPress. You know, the pages that show everything a single author has published on the site? It’s great if there are more than one author, but if there is only one or two, it is useless.
You can kind of disable Author Pages in WordPress by redirecting those links to the Home page.
- Open up your WordPress Admin page, then go to “Appearance” > “Theme Editor“.
- Select “Theme Functions (functions.php)” on the right pane.
- Add the following snippet of code to the end of the file, then select the “Update File” button.
function redirect_author_page() {
if ( is_author() ) {
wp_redirect( home_url() );
die;
}
}
add_action( 'template_redirect', 'redirect_author_page' );
If you want the author pages to go to a 404 error page instead, use this code:
function redirect_author_page() {
if ( is_author() ) {
status_header( 404 );
nocache_headers();
include( get_query_template( '404' ) );
die;
}
}
add_action( 'template_redirect', 'redirect_author_page' );
THANK YOU !!!
Your snippets work perfectly and are very simple to implement
This prevents author profile to be visible on internet with url
https://mysite.com/index.php/author/jdoe
and allows to be (more) compliant to GDPR
excellent
had a google search console problem
fixed it
thank you