经过大约100次不同的尝试,我终于成功了。不确定是否有更好的方法,但它确实有效。
$term_slug = get_query_var( \'term\' );
$taxonomyName = get_query_var( \'taxonomy\' );
$current_term = get_term_by( \'slug\', $term_slug, $taxonomyName );
$args = array(
\'post_type\' => \'clients\',
\'posts_per_page\' => -1,
\'orderby\' => \'title\',
\'order\' => \'ASC\',
\'tax_query\'=>array(
array(
\'taxonomy\'=>$taxonomyName,
\'field\'=>$term_slug,
\'terms\'=> $current_term,
)
)
);
<?php $query = new WP_Query($args); while ($query->have_posts()) : $query->the_post();?>
//stuff here
<?php endwhile; ?><?php wp_reset_query(); ?>