所以如果$trips_list
是示例trips部分,您希望示例trips只显示具有相同术语的trips-您可以在WP\\u查询中找到当前trips术语并进行论证。
// 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 );
我假设每次旅行只有一个学期。我已经添加了注释代码,以防一次旅行可能有多个。