3

I had a custom type post, for which I changed the url. I have refreshed permalinks and cleared site and browser cache. The old url now redirects to the new url automatically. Possibly because the post ID is the same (?). Is it possible the stop the old url to direct to the new url?

4
  • wordpress database migrate query apply ? Jan 29, 2018 at 12:36
  • 1
    Have you refresh permalinks in admin ?
    – Elex
    Jan 29, 2018 at 12:48
  • I have refreshed permalinks and cleared site and browser cache.
    – IXN
    Jan 29, 2018 at 12:54
  • 1
    search-replace plugin used and replace old url to new url wordpress.org/plugins/better-search-replace Jan 29, 2018 at 13:01

1 Answer 1

6

WordPress uses a function called wp_old_slug_redirect() to find out if you're looking for a post whose slug was recently changed and redirect you to its new home.

If you want to prevent this behaviour for this specific post, delete the _wp_old_slug post meta entry from the database for that post.

If you want to prevent this behaviour for all posts, prevent the function from being used at all:

remove_action( 'template_redirect', 'wp_old_slug_redirect' );
2
  • It worked - thanks. I went directly to the database with phpmyadmin, but here's another way to do it:wordpress.stackexchange.com/questions/238514/…
    – IXN
    Jan 29, 2018 at 20:10
  • We had a an auto updating woocommerce product with two very similar names and slugs and somehow wordpress added _wp_old_slug to create a redirect loop. 'Fantastic'. Jul 14, 2021 at 13:41

Your Answer

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

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