Question

I'm running a property site where many properties are sold in apartment blocks.

Because of this what the content editors do is create a post/property with all the details and then use a duplicate post plugin to create the others.

Each time they duplicate a post/property they change the title to reflect the property number and maybe change a few bits of meta data E.G price.

What they forget to do is wipe out the slug and let a new one be generated from the title. Here is an example slug from the first property entered:

merle-court-plot-50-182-carlton-vale-nw6-5hh

but then when they duplicate the slugs become:

merle-court-plot-50-182-carlton-vale-nw6-5hh-2
merle-court-plot-50-182-carlton-vale-nw6-5hh-2-2
merle-court-plot-50-182-carlton-vale-nw6-5hh-2-2-2
merle-court-plot-50-182-carlton-vale-nw6-5hh-2-2-2-2
etc

But when they change the titles the slugs would be better like:

merle-court-plot-51-182-carlton-vale-nw6-5hh
merle-court-plot-52-182-carlton-vale-nw6-5hh
merle-court-plot-53-182-carlton-vale-nw6-5hh
merle-court-plot-54-182-carlton-vale-nw6-5hh
etc

So my question:

How do I force the slug to be re-generated on post save, after they have updated the property title?

The slug for this CPT should always be auto generated, there is never a need to manually set it.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top