How To Prevent Old Post Slug Redirection In WordPress

How To Prevent Old Post Slug Redirection In WordPress

Every WordPress post has its on slug, which is automatically generated by your post’s title. If you decide to change the post slug later, WordPress will remember the old one and redirect it to the new one. It’s possible to prevent old post slug redirection in WordPress by adding removing a couple of actions from your WordPress core with a small snippet.

Just add following code to your current theme’s functions.php file to prevent WordPress from redirecting old post slugs to new ones:

Plus, you can also remove all the old post slugs from your WordPress’ MySQL by running following code to your theme’s functions.php file:

[alert style=”red”]Note: Please remove this code immediately after saving your functions.php file. You only need to run this code once, there’s no need to keep this code in your theme.[/alert]