1

We have a situation where we need to be able to do some categorization like this:

Root Category
  |-- Child Category
  |-- **Non-Unique Category**
Next Category
  |-- Next Level
        |-- **Non-Unique Category**
Another Category
  |-- **Non-Unique Category**

The problem we have found when creating categories is that the Slugs are unique. In our use-case, the slug doesn't get used in a URL so it could be a GUID for all we care, according to WordPress it just has to be unique.

If the slug is not unique WordPress throws an error saying that same name exists already. How can we use a filter/action to change the term slug value before it commits to the database?

Bonus: Can this be done with Custom taxonomies as well as builtins?

1 Answer 1

1

You can use the pre_insert_term filter to do just this

https://developer.wordpress.org/reference/hooks/pre_insert_term/

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.