How to disable WordPress redirecting missing 404 URLs

Looking to disable WordPress from guessing page-not-found URLs (error 404)? Here’s a quick guide on how you can do this.

Disabling 404 URL guessing in WordPress

In order to disable the 404 page-not-found URL guessing system in WordPress, you’ll need to add the following code into your theme’s functions.php file.

add_filter( 'do_redirect_guess_404_permalink', '__return_false' );