While loop through posts in archive and get categories list with no duplicates
-
I want to get the hierarchical list of terms for a taxonomy for every post in an archive, I have this which works but I get duplicates
<?php $array_out = array(); while (have_posts()) : the_post(); $taxonomy = 'workflow-type'; // change this to your taxonomy $terms = wp_get_post_terms( $post->ID, $taxonomy, array( "fields" => "ids" ) ); if( $terms ) { echo '<ul>'; $terms = trim( implode( ',', (array) $terms ), ' ,' ); wp_list_categories( 'title_li=&taxonomy=' . $taxonomy . '&include=' . $terms ); echo '</ul>'; } endwhile; ?>
Not sure how to remove the duplicates for the lists. Any help? What im looking for is
Parent (a)
-Children
Parent (b)
-Childrenbut I get something like
Parent (a)
– Child
Parent (a)
– Child
Parent (b)
– Child
Parent (a)
– Child
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘While loop through posts in archive and get categories list with no duplicates’ is closed to new replies.