How to remove comma from last item category list?
-
I am retrieving a list of child categories from a parent category with a common separating the list but can’t figure out how to remove the last comma of the list. Any one can point me in the right direction? Thanks.
<?php
foreach((get_the_category()) as $childcat) {
if (cat_is_ancestor_of(16, $childcat)) {
echo $childcat->cat_name . ‘,’;
}}
?>
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
- The topic ‘How to remove comma from last item category list?’ is closed to new replies.