There have been times when I have needed to get a list of terms (or one specific term) from a custom taxonomy to output on a page template, but using ‘get_the_terms’ outputs each term as a clickable link.
To list the terms without links, use the following:
$terms = get_the_terms($post->ID, 'taxonomy'); // change 'taxonomy' to the slug of your custom taxonomy
if($terms != null) { // if there is data returned
$output = array();
foreach($terms as $term) { // loop through the results
$output[] = $term->name; // add the term name to an array
unset($term);
}
echo implode(", ", $output) // separate each object in the array by a comma
}
Did this help you?
Whether you have a question, want to learn more about our services, or simply wish to connect, don’t hesitate to get in touch. We’re here to help!
Send an email"*" indicates required fields