Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Display categories in single-cpt.php
<?php
if ( is_singular('YOUR_CUSTOM_POST_TYPE') ) {
$terms = get_the_terms($post->ID, 'custom_categories');
foreach ($terms as $term) {
$term_link = get_term_link($term, 'custom_categories');
if (is_wp_error($term_link))
continue;
echo '<a href="' . $term_link . '">' . $term->name . '</a>, ';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.