谢谢你的回答,但当我测试时,除了type\\u partenaires之外,什么都不会显示。
我想我对我的问题的解释是错误的。很抱歉
我希望能够按“partners\\u order”字段进行排序。此字段位于$循环之后的my while中
<?php $terms = get_terms(\'type_partenaires\');
usort($terms, function($a, $b) {
return get_field(\'ordre_affichage\', $a) - get_field(\'ordre_affichage\', $b);
});
foreach ( $terms as $term ): ?>
<div class="cell small-12 medium-12 large-12">
<h2 class="title-type-partenaire"><?php echo $term->name; ?></h2>
</div>
<?php
$loop = new WP_Query( array(
\'post_type\' => \'partenaires\',
\'orderby\' => \'title\',
\'order\' => \'ASC\',
\'posts_per_page\' => -1,
\'paged\' => $paged,
\'tax_query\' => array(
array(
\'taxonomy\' => \'type_partenaires\',
\'field\' => \'ID\',
\'terms\' => $term->term_id,
),
),
) ); ?>
<div class="cell large-12">
<ul class="flex-partenaire">
<?php if (have_posts()) : while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php get_template_part( \'template-parts/loop\', \'page-partenaires\' ); ?>
<?php endwhile; ?>
</ul>
</div>