Get a posts taxonomy terms as text – can use for dynamic queries

Echoing the list of terms (for a taxonomy called on-draught). This is similar to the output from get_the_term_list, but without the terms being hyperlinked:

<?php
$terms = get_the_terms( $post->ID, 'on-draught' );
						
if ( $terms && ! is_wp_error( $terms ) ) : 

	$draught_links = array();

	foreach ( $terms as $term ) {
		$draught_links[] = $term->name;
	}
						
	$on_draught = join( ", ", $draught_links );
?>

<p class="beers draught">
	On draught: <span><?php echo $on_draught; ?></span>
</p>

<?php endif; ?>

Revisions

There are no revisions for this post.

Tags: ,

No comments yet.

Leave a Reply