Reputation: 13
I want to display a custom post type for doctors and its custom categories,for example is pediatrician, and use builtin functions such as the content and the category for that post. The problem I'm facing is that I can't display the custom category of the custom post type. How can I achieve it?
custom category
builtin function to display category
output
Upvotes: 1
Views: 58
Reputation: 16
Try this
<?php $terms = get_the_terms($post->ID, 'yourtaxonomyhere');
foreach ($terms as $term) {
$term_link = get_term_link($term, 'yourtaxonomyhere');
if (is_wp_error($term_link))
continue;
echo '<a href="' . $term_link . '">' . $term->name . '</a>';
}
?>
Also see: https://developer.wordpress.org/reference/functions/get_the_terms/
Upvotes: 0