Have multiple ACF galleries with 100+ items. Each image attachment has simple custom taxonomy (artist). No problem getting the taxonomy term for an individual item. But, how can I count the individual values of the terms and create a ul list based of ONLY the unique values? Count would be good too, but not necessary. Ie, artist1 (3), artist2 (4), etc. get_terms() doesn’t work since all artists may not appear within the current query loop.
The only way that I can think of to do this is to loop over them all, get the terms and build an array of artists where
$artists = array(
$artist_ID => $count
)
where the term ID for each artist is the array index and the you increment that array index for each one you find.
if (!isset($artists[$term_id])) {
$artists[$term_id] = 0;
}
$artists[$term_id]++;
Then the indexes are the unique values and the value of each index is the count.