Support

Account

Home Forums Add-ons Gallery Field UL list from custom taxonomies

Solving

UL list from custom taxonomies

  • 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.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.