Removing unnecessary numbers appended to postname in permalinks

There is a plugin for wordpress which allows you to handle 404 errors and redirect to specific pages. So if wordpress calls your post /events/2013/june/fishing-trip-2, you could go into the plugin and add a rule so that /events/2013/june/fishing-trip points to /events/2013/june/fishing-trip-2.

It’s not a perfect solution, as you’d have to manually enter each duplicate post name to the rewrite rules, and even then the links wordpress generates for that post would still have the -2. You could write a function using preg_replace to then remove any -2 or -3 or whatever from the end of a link, but it’s a little messy

Leave a Comment