1

I have a client that saves pretty much everything as draft before posting it on the website.

Thing is, he has a 'Jobs' section, where the name of the job offers might repeat. If they are looking for Technicians in two locations ate the same time for instance, they will create 2 posts called 'Technician' and taxonomies will differentiate between the both of them.

The problem is that by saving the post as a draft first, and then publishing it, the slug created doesn't seem to care if that slug is already taken. For example, both 'Technician' posts will have the slug '/technician/' and not '/technician/' and '/technician-2/'.

Is there any way to make Wordpress check for slug availability before assigning the slug to the post when they save it as draft?

PS: I know I can modify the slug manually, but the client doesn't want to bother.

1 Answer 1

1

I just ran a quick test and there shouldn't necessarily be a "slug" -- post_name in the $wpdb->posts table-- until the post is published, so something is going wrong with your site-- something has been modified.

WordPress already checks for duplicate slugs. This is pretty critical functionality as certain permalink structures depend upon it. The function used is wp_unique_post_slug(). You can see it used in wp_insert_post()

Your Answer

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

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