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?