Sort by an ACF field in a tax_query

Question

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

0
, , PIxel up 2 years 2020-01-01T08:38:21-05:00 0 Answers 98 views 0

Leave an answer

Browse
Browse