Permalinks - Script to Clean-up Old Entries

Hello, All -

Would it be possible to have a plugin (run as a cron job) that cleans up the Permalink database? It would be great to have something that went through the list every night and removed all of the "old" entries.

Just a thought.

:0)

Perch

By Daryl - August 24, 2016

Hi Perch,

Yes, that's doable.

But why would you want to delete the old entries?

We use the old permalinks to redirect the users to the current ones.
This is useful if a user bookmarked an old URL, or search engines haven't indexed the new URL yet and referred the user to the old one.

Cheers,

Daryl Maximo
PHP Programmer - interactivetools.com

Hi, Daryl -

I'm coming up against a client who wants perfect control over the Permalinks. It involves a lot of experimentation on their part and almost always ends-up in a conflict. They choose a Permalink, then another, then want to go back to the original, etc, etc....

With the current set-up there is no way to go back to an old Permalink because it's "reserved". I can't see any other way of freeing-up an old Permalink other than by deleting it.

Happy to hear suggestions!

:0)

Perch

By Daryl - August 24, 2016

If that's the case, you can modify the permalinks plugin (create a backup first) to delete the old permalink as you add a new one.

You can do that by changing the code that updates the old permalink to mark it as "old" to have it delete the old record instead.

You can find that code in the permalink_add() function.

I'd comment out the code that updates the record instead of deleting it so I can restore it back easily when I need to.

Daryl Maximo
PHP Programmer - interactivetools.com

Hi, Daryl -

Thanks for this - but could you be a bit more specific, please! I can't seem to find the code in the plugin.

:0/

Perch

Got it. Thanks.

:0)