Display list of custom taxonomies that are related to a particular post on your single page

Marko Krstić
27 Dec 2019
<?php
	global $post;
	$terms = get_the_terms( $post->ID, 'projekte_cat' );
		foreach ($terms as $term) {
	    $term_id = $term->term_id;
  		$term_name = get_term( $term_id )->name;
		$term_slug = get_term( $term_id )->slug;
  	echo '<div class="'.$term_slug.'">'. $term_name . '</div>';
}
?>

Replace “projeckte_cat” with your taxonomy slug.

Was this article helpful?

Tags

Categories

Never miss new post again

Subscribe and get list of new posts in your inbox

Click to Copy