Created
October 25, 2017 17:50
-
-
Save guilhermealveslopes/d31c2a7f2976da48a74679d77052d298 to your computer and use it in GitHub Desktop.
Remove 'adivinhação' de URL por parte do 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
// Por padrão ao digitar uma URL incompleta, o wordpress faz uma busca por algum post ou página | |
com slug similar. Com o snippet abaixo, ele simplesmente redireciona para a página 404 se o termo digitado não existe. | |
function no_redirect_guess_404_permalink( $header ){ | |
global $wp_query; | |
if( is_404() ) | |
unset( $wp_query->query_vars['name'] ); | |
return $header; | |
} | |
add_filter( 'status_header', 'no_redirect_guess_404_permalink' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment