loop through posts and get the list of all terms for a taxonomy
-
Im within taxonomies (a) archive and I want to loop through all the posts and retrieve a list of terms for taxonomy (b) then echo that list out with no duplicates. Forgive me as I am new to wordpress and php but here’s what I have so far in my taxonomy.php.
<?php while (have_posts()) : the_post();
$terms = get_the_term_list( $post->ID, ‘role-type’, ‘ Role(s): ‘, ‘ ‘, ‘ ‘ );
echo $terms;
endwhile; ?>Lets say there are three posts in the archive this then displays the following
Role(s): DOS FE RSM RSS Role(s): DOS FE SPMs RSS Role(s): CSO
What it should do is display something similar to: Role(s): DOS FE RSM RSS SPMS CSO
What do I need to do? Thanks for your help
- The topic ‘loop through posts and get the list of all terms for a taxonomy’ is closed to new replies.