The other day I was going through all the errors found on Google Search Console and I encountered an unexpected behavior.
if you write the URL of a page in a WordPress site incorrectly, WordPress will try to guess what page you were trying to access and redirect the visitor to the right page.
The problem with this functionality is that sometimes its guesses are wrong pretty much all the time.
Fortunately, there are ways to stop WordPress from autocompleting URLs
How to Stop WordPress From Guessing URLs
If you don’t mind installing one more plugin, you can prevent WordPress from guessing URLs using the Disable URL Autocorrect Guessing plugin.
If you don’t feel like installing a plugin that hasn’t been updated in two years, you might want to use a better approach.
This code will prevent WordPress from attempting to redirect to a “guessed” URL when a 404 error page is encountered. Instead, it will allow the 404 error page to be displayed.
function remove_redirect_guess_404_permalink( $redirect_url ) {
if ( is_404() ) {
return false;
}//end if
return $redirect_url;
}//end remove_redirect_guess_404_permalink()
add_filter( 'redirect_canonical', 'remove_redirect_guess_404_permalink' );
You can insert that code to your Functions.php file via a custom plugin, a child theme, or a code snippet plugin
More Code Snippets for WordPress
You might want to check out some of these posts before you leave