Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanpejcic/96013d05fb61f964cb68d227417c291c to your computer and use it in GitHub Desktop.
Save stefanpejcic/96013d05fb61f964cb68d227417c291c to your computer and use it in GitHub Desktop.
Disable author pages in WordPress
//Check if it is author page
function remove_author_pages_page() {
if ( is_author() ) {
//trigger 404 page
global $wp_query;
$wp_query->set_404();
status_header( 404 );
}
}
//redirect to homepage
function remove_author_pages_link( $content ) {
return get_option( 'home' );
}
//when
add_action( 'template_redirect', 'remove_author_pages_page' );
//do
add_filter( 'author_link', 'remove_author_pages_link' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment