Skip to content

Instantly share code, notes, and snippets.

@accrane
Created December 28, 2020 14:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save accrane/2fefe4ce15022e54c5f886818e3bd233 to your computer and use it in GitHub Desktop.
WordPress Prevent Author Lookup
function redirect_to_home_if_author_parameter() {
$is_author_set = get_query_var( 'author', '' );
if ( $is_author_set != '' && !is_admin()) {
wp_redirect( home_url(), 301 );
exit;
}
}
add_action( 'template_redirect', 'redirect_to_home_if_author_parameter' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment