You can use get_the_terms()
. I've adapted the following from an example on that page:
$terms = get_the_terms( $post->ID, 'visits' );
if ( $terms && ! is_wp_error( $terms ) ) :
$visits_name = array();
foreach ( $terms as $term ) {
$visits_name[] = $term->name;
}
endif;
$terms_list = join( ", ", $visits_name );
echo $terms_list;
EDIT:
Using wp_list_pluck
, as suggested by Telos, is much easier:
$terms = get_the_terms( $post->ID, 'visits' );
if ( $terms && ! is_wp_error( $terms ) ) :
echo join( ',', wp_list_pluck( $terms, 'name' ) );
endif;