Home › Forums › General Issues › Order by ACF › Reply To: Order by ACF
<?php
$args = array(
'taxonomy' => 'sock-club',
'hide_empty' => '0'
);
$terms = get_terms('sock-club', $args);
if ($terms) {
foreach ($terms as $index => $term) {
$terms[$index]->star_rating = get_field('star_rating', $taxonomy.'_'$term_id);
}
usort($terms, 'my_sort_function');
// create the list after the terms are sorted
// need to loop through them again
$term_list = '';
foreach ($terms as $term) {
$term_list .= '<a href="' . get_term_link( $term ) . '" title="' . sprintf( __( 'View all post filed under %s', 'my_localization_domain' ), $term->name ) . '">' . $term->name . '</a>';
}
}
?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.