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' );
Leave a Reply