Let's say that we have three custom post types: museum, theater and restaurant that share the same hierarchical taxonomy: location

Up till now I have 3 different urls for each of cpt archive pages:
and single pages for custom posts with urls like: /museum/national-museum

What I want is to get the link of the relevant term on both the archive and single pages of the other two custom post types. So if we are on page /museum/location/city-a or on page /museum/national-museum, which has term "city-a", I want to get the links /theater/location/city-a and /restaurant/location/city-a.

I can get the term id on the archive page with get_queried_object()->term_id and on single pages with wp_get_object_terms( $post_id, 'location', array( 'orderby' => 'term_order', 'order' => 'ASC', 'fields' => 'ids' ) ) but all native wp functions allow to get the link of the terms for the current cpt only.

Is there a solution?

  • Do you still need an answer to this? Jul 23, 2016 at 14:46
  • Yes, please, I do need an answer!
    – vadims
    Jul 26, 2016 at 12:09
  • Can you add your code for registering the post types and taxonomy so I can understand the URL rewrites better? Jul 26, 2016 at 12:11
  • Then I'll have a go at answering. Jul 26, 2016 at 12:40


Your Answer

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