Skip to content

Instantly share code, notes, and snippets.

@knolaust
Last active January 30, 2024 14:52
Show Gist options
  • Save knolaust/55168d4e4112fcf3d0f85576187b731b to your computer and use it in GitHub Desktop.
Save knolaust/55168d4e4112fcf3d0f85576187b731b to your computer and use it in GitHub Desktop.
Redirect Wordpress Author Pages to Home
<?php
/**
* Redirect Author Page to Home
*
* Gist Keywords: wordpress, author page, redirect
* Author: Knol Aust
* Version: 1.0.0
*
* This function redirects the Author Page to the home page with a 301 permanent redirect.
*/
function knolaust_redirect_author_page() {
global $wp_query;
if ( is_author() ) {
// Redirect to home, set status to 301 permanent or 302 temporary
wp_redirect(get_option('home'), 301);
exit;
}
}
add_action('template_redirect', 'knolaust_redirect_author_page');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment