I am populating my database directly from another database and I do have some hierarchies like:

A > B > C


D > C > E.

This means that I do have the same terms, in the same taxonomies in different hierarchy levels (with different parents in term_taxonomy_table).

Taxonomy archive now gets posts from all terms with the same name... Is there any way to make taxonomy template work properly with this setup?

If so, which filter(s) can I use to handle this by myself?


  • In short - no. WordPress is built to handle unique terms, and when you have multiples named the same thing - even if they're not in the same taxonomy - it is easily confused about what you're requesting. Perhaps you could clarify why you're populating directly from another database, yet using different hierarchies, so we could suggest other options? – WebElaine Jul 13 '17 at 19:15
  • I am using WooCommerce and the hierarchy items are the product's categories, as Luggage > backpacks > acessories and Kitchen > accessories > forks – Bruno Rodrigues Jul 13 '17 at 19:24
  • Since slugs have to be unique within given taxonomy, I don't see how you could have the same accessories slug in different branches of your categories tree. – Picard Jul 13 '17 at 19:45
  • just tried this (needs improvements), but it seems to work: pastebin.com/tkKSMGeL – Bruno Rodrigues Jul 13 '17 at 20:14
  • Using pre_get_posts... I am basically forcing a tax_query by slug for a tax_query by term_id. Is this idea valid or will it break somehow? – Bruno Rodrigues Jul 13 '17 at 20:16

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.