0

I understand that since 4.4 or so, taxonomies no longer share terms. But I have a use-case where I think I need shared terms.

For each post, I need two taxonomies: a Topic (unimited terms per post) and a Primary Topic (one term per post).

This is because a post may have topic terms for Politics, Health, and Economy, but if the primary topic is Health and I will want to use Health to build the URL.

example: mysite.com/news/health/some-headline-here
tags: health, economy, politics
  1. I could build this with two taxonomies with identical but non-shared terms. The problem with this approach is the editors will need to duplicate their efforts and make sure "health" term is applied in both taxonomies. But then what about archives? Primary Topic: Health will generate a different archive than Topic: Health, because Primary Topic Health archive will show no content with only Topic Health tags. I'd need to make some custom multi-taxonomy queries for archives.

  2. Or if I could have two taxonomies sharing the term, then a site visitor clicking the term will get the correct "health" term archive regardless if health is checked in Topic or Primary Topic. Since it's a singular shared term, it generates a singular archive.

Any advice, or perhaps an entirely different approach?

  • Shared terms would not have been the solution anyway, adding a term to one tax wouldn't make it appear in the other, it would just use the existing term if you went and added it to both taxonomies- but you would still need to add it to both, and they would not share an archive. It was really more of an internal thing that only presented itself in buggy, non-useful ways. I would maybe look into just using a single taxonomy and saving a reference to the primary term in post meta. That way you can hook post_link and insert the correct term in the URL yourself. – Milo Jul 23 '17 at 1:56
  • "I would maybe look into just using a single taxonomy and saving a reference to the primary term in post meta." Can you add a little detail to this? It sounds like it's the answer I'm looking for. – Slam Jul 24 '17 at 3:23

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.