Get taxonomy terms for all wordpress posts in the archive


Junaid Farouk

I am using the following function to display selected taxonomy terms in archive page.

echo get_the_term_list( $post->ID, 'dt_portfolio_category', '<ul class="styles"><li>', ',</li><li>', '</li></ul>' );

The above function only displays the taxonomy terms for the first article, not all of them.

What is the solution? Also, terms should not be repeated, they should only appear once.

Sadly

Please run the code inside the loop. Hope to do so.

Sample code:

while ( have_posts() ) : the_post();
    echo get_the_term_list( $post->ID, 'dt_portfolio_category', '<ul class="styles"><li>', ',</li><li>', '</li></ul>' );
endwhile;

Related