On one of my pages I changed the slug to form a different URL. E.g.

Old: http://example.com/old-slug

New: http://example.com/new-slug

WordPress has done it’s thing of redirecting http://example.com/old-slug to http://example.com/new-slug.

I’d like to remove this behaviour as a plugin I am using makes use of the slug in question and the redirect overrides its behaviour.

I checked this question, and checked my wp_postmeta table for instances of _wp_old_slug but nothing is returned. My server is Nginx so shouldn’t be affected by .htaccess files.

Is there anything else I can do to remove this redirect?

5 s
5

This (in your functions.php) will turn it off (but see also the comment I’ve left):

remove_action('template_redirect', 'wp_old_slug_redirect');

It seems odd that your wp_postmeta table wouldn’t have any _wp_old_slug keys – the bit of code that does that is in wp-includes/query.php (wp_old_slug_redirect()) – you could add an exit or debug statement there to check if it’s being called.

Also, remember that if WordPress can’t find a permalink, it looks for posts with a matching beginning, e.g. if you had a post with permalink /foobar, then /foo will redirect to it.

Leave a Reply

Your email address will not be published. Required fields are marked *