Skip to content

Instantly share code, notes, and snippets.

@patrickposner
Created July 17, 2018 11:08
Show Gist options
  • Select an option

  • Save patrickposner/723d318c29f4fdb951a94bf5ae89b004 to your computer and use it in GitHub Desktop.

Select an option

Save patrickposner/723d318c29f4fdb951a94bf5ae89b004 to your computer and use it in GitHub Desktop.
/* "wp" is the earliest possible hook before rendering a page */
add_action( 'wp', 'disable_author_page' );
function disable_author_page() {
/* get global $wp_query object */
global $wp_query;
/* If an author page is requested, answer with 404
if ( $wp_query->is_author ) {
$wp_query->set_404();
status_header( 404 );
get_template_part( 404 );
exit();
}
*/
/* If an author page is requested, redirect with 301 */
if ( $wp_query->is_author ) {
wp_safe_redirect( get_bloginfo( 'url' ), 301 );
exit;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment