Skip to content

Instantly share code, notes, and snippets.

@petersplugins
Last active June 21, 2017 11:12
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 petersplugins/e852568153f60d9617fe9c5f40efb8d7 to your computer and use it in GitHub Desktop.
Save petersplugins/e852568153f60d9617fe9c5f40efb8d7 to your computer and use it in GitHub Desktop.
<?php
// This code snippet disables the URL autocorrection guessing feature of WordPress
// Add a custom function to disable autocorrection guessing
add_filter( 'redirect_canonical', 'stop_url_autocorrect' );
function stop_url_autocorrect( $redirect_url ) {
if ( is_404() && !isset( $_GET['p'] ) ) {
$redirect_url = false;
}
return $redirect_url;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment