I am trying to get taxonomies terms names separated with a comma. This is the code, but it separates taxonomies and terms with : If there are many terms they get separated with : instead of , If I delete the : symbol there are nothing in between taxonomy terms names.
<ul class='apt-product-terms'>
<?php
$_taxonomies = array(
'taxname1' => __( 'Taxname1', 'textstringdomain' ),
'taxname2' => __( 'Taxname2', 'textstringdomain' ),
'taxname3' => __( 'Taxname3', 'textstringdomain' ),
'taxname4' => __( 'Taxname4', 'textstringdomain' )
);
foreach ($_taxonomies as $taxonomy_slug => $taxonomy_name) {
$terms = get_the_terms( $post->ID, $taxonomy_slug);
if (is_array($terms) && count($terms) > 0) { ?>
<li class='apt-tax-item'>
<span class='apt-term-name'><?php echo $taxonomy_name ?></span>
<ul class='apt-tax-term-list'>
<?php foreach ( $terms as $term ) { ?>
<li class='apt-term-item'>:
<a class='apt-term-link' href="<?php echo get_term_link($term); ?>"> <?php echo $term->name ?></a>
</li>
<?php } ?>
</ul>
</li>
<?php
}
}
?>
</ul>
Where is the problem. I think it might be related to echo $term->name