Is it possible to organize a list of repeating elements by a taxonomy? I created a list of the communities at the top of the page that links down to each community (repeating element). My client would like me to group them by a geographic term that I added to each one. The list should display like this:
NORTH
Community 01
Community 02
South
Community 01
Community 02
This is the code I currently have that links down to the ID I added to each row. My question is can I group each community name by the different taxonomy terms?
<ul>
<?php
$i = 1;
while(has_sub_field('communities')):
echo '<li><a href="' . get_permalink() . '#community-' . $i . '">' . get_sub_field('community_name') . '</a></li>' ;
$i++;
endwhile;
?>
</ul>