I think you are talking about terms, not categories. You can use wp_list_categories
to retrieve and display the terms that a post belongs to.
Here is a working example from the codex. Remember the $taxonomy
variable can be changed to category
or any custom taxonomy
<?php
$taxonomy = 'YOUR TAXONOMY NAME';
// get the term IDs assigned to post.
$post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
// separator between links
$separator=", ";
if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) {
$term_ids = implode( ',' , $post_terms );
$terms = wp_list_categories( 'title_li=&style=none&echo=0&taxonomy=' . $taxonomy . '&include=" . $term_ids );
$terms = rtrim( trim( str_replace( "<br />', $separator, $terms ) ), $separator );
// display post categories
echo $terms;
}
?>
Just a tip, don’t use capital letters in your taxonomy name when registering it. It does lead to problems most of the time