0

I want to use the same Tag slug for different Tags.
My URL structure will be unique basing on the category, but post_name and post_tag may happen to be duplicate in some cases.

I need this for good reason, because Tags will be multi-language, meaning that the Tag Violin will be assigned to the Professor (post) of Violin but the same Professor will also have another post, with same name but with Tag Violino, in Italian. Problem is that some Tags are identical in both EN and IT, Piano for example is the same.

Example:
mysite.com/professor/piano/professor-name
mysite.com/i-professori/piano/professor-name

I know there is a filter called wp_unique_post_slug and it worked perfectly when allowing same-slug-posts (found here), and I looked up on google for something like wp_unique_post_tag_slug but the latter does not seem to exist.

  • 1
    I don't know if you can, for example if I call get_term_by('name', 'piano', 'tag') which one would it return? If you could somehow smush that into the database, it'll always return the first it finds, making the second URL redirect to the first – Tom J Nowell Mar 31 at 11:32
  • 1
    There's wp_unique_term_slug, but I agree with Tom - slugs for terms within the same taxonomy should always be unique. And you could instead use URL rewriting to have piano in both the URLs. – Sally CJ Mar 31 at 11:52
  • So, I'll better use pages for the Professor type or a hierarchical custom post type – Nicola Mar 31 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.