Sort by an ACF field in a tax_query
I do not find the solution which must surely be surely simple. (I'm new to WP) I have an ACF field named "partners_order". I would like to sort it in ascending order (ASC)
here's what i tried
?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 ): ?
?php echo $term-name; ?
?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,
'orderby' = 'partners_order',
'order' = 'ASC',
),
),
) ); ?
if someone could give me a lead to move forward ... thank you
Topic tax-query order custom-field Wordpress
Category Web