我联系了Scribu,因为他的Query Multiple Taxonomies插件做了我想做的事情,他为我指明了正确的方向。我(在我的开发环境中)已经做到了这一点,所以我想就是这样了。(Scribu将这些函数作为一个类的一部分拆分为两个函数-我相信这是一种“优雅”(非故意的双关语)的方式-但这是内联的:(在这里发布,以防对其他人有帮助…)
//building this as if we were going to look for
//posts that have been categorized with this service
$tempargs = array(\'post_type\' => \'vendors\',
\'tax_query\' => array(array(
\'taxonomy\' => \'service\',
\'field\' => \'id\',
\'terms\' => intval($_GET[\'srv\'])
))
);
$args = array_merge( $tempargs, array(
\'fields\' => \'ids\',
\'nopaging\' => true,
\'no_found_rows\' => true,
\'ignore_sticky_post\' => true,
\'cache_results\' => false,
) );
$query = new WP_Query;
$filtered_ids = $query->query( $args );
//now getting the list of location terms that have posts in this service
$locationsWdups = wp_get_object_terms( $filtered_ids, \'location\' );
//the above will include duplicate locations so we\'ll combine them
//into one array below
$locations = array();
foreach ( $locationsWdups as $singloc )
$locations[ $singloc->term_id ] = $singloc;
然后您可以在$位置上执行foreach。。。
(如果我遗漏了什么或做得不正确,请纠正我)