我有以下脚本,需要按字母顺序对内部foreach循环进行排序,但没有成功。
$args = array(
\'post_type\' => \'clinical_sites\',
\'tax_query\' => array(
\'relation\' => \'AND\',
array(
\'taxonomy\' => \'research\',
\'field\' => \'slug\',
\'operator\' => \'AND\',
\'hide_empty\' => false,
\'terms\' => $researchName
),
array(
\'taxonomy\' => \'country\',
\'hide_empty\' => false,
\'operator\' => \'IN\',
\'field\' => \'term_id\',
\'terms\' => $fatherTermId
),
),
\'hide_empty\' => true,
\'posts_per_page\'=>-1,
\'parent\' => \'1\'
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while( $query->have_posts() ) { $query->the_post();
$args3 = array(
\'orderby\' => \'ID\',
\'order\' => \'DESC\',
\'childless\' => true
);
$terms = wp_get_object_terms( $post->ID, \'country\', $args3 );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
foreach ( $terms as $parent_term ) {
?><option value="<?=$parent_term->name; ?>" data-is-parent="<?=$isparent?>" data-term_id="<?=$parent_term->term_id; ?>" ><?php echo $parent_term->name?></option><?php
}
}
}
}
我们将不胜感激。