I'm working with the WooCommerce plugin. I've got three products (called "Kits") and each kit contains several items. The "items" are a custom post type which are linked to each kit via a relationship field. Each item has a custom taxonomy attached to it ("departments"). The departments have no direct link to the products (or "kits"), except via the items.
When I display the products, I want them to show a
<ul> that loops through each term found in "departments". Then within that
<li>, have a nested
<ul> that lists each item that is found in the current department AND in the current product.
I've got a loop that's working to display the items associated with each product:
<a href="#details<?php the_ID(); ?>" class="details button" data-id = "<?php the_ID() ?>">Details</a> <div class="items" id="details<?php the_ID(); ?>"> <?php $items = get_field('kit_items');?> <?php if( $items ): ?> <ul> <?php foreach( $items as $item ): ?> <?php $ident = $item->ID ?> <li> <a href="#overlay<?php echo $ident ?>" class="item item<?php echo $ident ?>" data-id ="<?php echo $ident ?>"> <?php echo get_the_title( $item->ID ); ?> </a> </li> <?php endforeach; ?> </ul> <?php endif; ?>
But I'm not sure how to query the custom taxonomy, print out the terms and then print the items that are associated with the department and the current product.