WordPress – redirecting the user for restricting the author archive pages

Below is the function for redirecting the user for restricting the author archive pages, please add to current_theme/functions.php, this will redirect to the home url.


function author_archive_redirect() {

if( is_author() ) {

wp_redirect( home_url(), 301 );

exit;

}

}

add_action( 'template_redirect', 'author_archive_redirect' );

Special Thanks : Supriya Surve

Share on Facebook