Created
July 20, 2019 20:21
-
-
Save stefanpejcic/96013d05fb61f964cb68d227417c291c to your computer and use it in GitHub Desktop.
Disable author pages in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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