Comma between subcategory list
-
In my single.php file I am trying to list all the child categories under a specific parent category. I’m using the following code:
if(!function_exists('subcat')){ function subcat(){ global $post; foreach((get_the_category()) as $category) { if ($category->category_parent == "177") { echo '<a href="' . get_category_link($category->cat_ID) . '">' . $category->cat_name . '</a>'; } } } }
The code works, but in instances where there are multiple subcategories I would like to separate those subcategories with a comma. How do I do that? Anyone know?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Comma between subcategory list’ is closed to new replies.