1

I have a site with custom post types "books" and I just noticed that if you do site.com/[segementofBookName]

Wordpress redirects me to a post with that name or similar. I'm trying to figure out how to disable this, so that you can only navigate to a page if you know the exact url string.

So in other words, I have the following posts, type="books": To Kill a Mockingbird The Giver A Christmas Carol

If someone goes to mysite.com/carol, it will go to the post for A Christmas Carol. If someone goes to mysite.com/mockingbird it will find the post for "To Kill a Mockingbird". I would like to disable this functionality.

Any help would be greatly appreciated.

0

1 Answer 1

3

There's a filter to remove this feature, which is known more commonly as autocorrecting the URL rather than "search" per se. Place this in your site-specific plugin or your custom/child theme's functions.php file:

remove_filter('template_redirect', 'redirect_canonical');

There is also an old plugin that does this. See https://www.bloggersignal.com/stop-wordpress-from-guessing-urls/ for details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.