Skip to content

Instantly share code, notes, and snippets.

@guilhermealveslopes
Created October 25, 2017 17:50
Show Gist options
  • Save guilhermealveslopes/d31c2a7f2976da48a74679d77052d298 to your computer and use it in GitHub Desktop.
Save guilhermealveslopes/d31c2a7f2976da48a74679d77052d298 to your computer and use it in GitHub Desktop.
Remove 'adivinhação' de URL por parte do Wordpress
// 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