so if $trips_list
is the sample trips section, and you want the sample trips to only show trips with the same terms – you’d find the current trips term and argue that in your WP_Query.
// this trips terms
$tripTerms = wp_get_post_terms( get_the_ID(), 'reisezweck');
// if each trip only has one term (as its a location)
// we'll use the first of the array array of terms
// and we'll now have our current trips term
$tripTerm = $tripTerms[0]->slug;
// you can uncomment and use instead if it's possible a trip has multiple terms:
// make an array of ID of current trips terms
/* $tripTerm = array();
foreach ($tripTerms as $aTripTerms)
$tripTerm[] = $aTripTerms->slug; */
$args = array(
'post_type' => 'ausfluge',
'showposts' => 3,
'orderby' => 'rand',
'tax_query' => array(
array(
'taxonomy' => 'reisezweck',
'field' => 'slug',
'terms' => $tripTerm,
),
),
);
$trips_list = new WP_Query( $args );
I’ve assumed each trip would have only one term. I’ve added commented code incase a trip could have multiple.