Stop WordPress from Guessing URLs

Posted on October 5, 2016 at 4:25 pm

WordPress can guess URLs if they do not exist. For example, if user visits queryadmin.com/abc and the page does not exists, WordPress tries to find posts that contain “abc” string in the permalink. Personally I don’t like this behaviour so I prefer to stop WordPress from guessing URLs. Add this to your functions.php file:

add_filter('redirect_canonical', 'stop_wp_guessing_urls');
function stop_wp_guessing_urls($url) {
 if (is_404()) {
   return false;
 }
 return $url;
}

Receive updates via email

Other Posts

Updated Posts