0

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:
/museum/location/city-a
/theater/location/city-a
/restaurant/location/city-a
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? – Andy Macaulay-Brook Jul 23 '16 at 14:46
  • Yes, please, I do need an answer! – vadims Jul 26 '16 at 12:09
  • Can you add your code for registering the post types and taxonomy so I can understand the URL rewrites better? – Andy Macaulay-Brook Jul 26 '16 at 12:11
  • Then I'll have a go at answering. – Andy Macaulay-Brook Jul 26 '16 at 12:40

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.