Title: wp_get_object_terms comma separated
Last modified: August 21, 2016

---

# wp_get_object_terms comma separated

 *  Resolved [greencode](https://wordpress.org/support/users/greencode/)
 * (@greencode)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/wp_get_object_terms-comma-separated/)
 * I’m using the following code to get a list of custom taxonomy terms that then
   get added to the post:
 *     ```
       <?php
       $product_terms = wp_get_object_terms($post->ID, 'skill');
       if(!empty($product_terms)){
         if(!is_wp_error( $product_terms )){
           echo '<ul>';
           foreach($product_terms as $term){
             echo '<li><a href="'.get_term_link($term->slug, 'skill').'">'.$term->name.'</a></li>';
           }
           echo '</ul>';
         }
       }
       ?>
       ```
   
 * This is displayed as list of terms. What I would like is to have a comma separated
   list with the last item not having a comma.
 * Is this possible?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [greendemiurge](https://wordpress.org/support/users/greendemiurge/)
 * (@greendemiurge)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/wp_get_object_terms-comma-separated/#post-4101685)
 * Does this work for you?
 *     ```
       <?php
       $product_terms = wp_get_object_terms($post->ID, 'skill');
       if(!empty($product_terms)){
         if(!is_wp_error( $product_terms )){
   
       	$numItems = count($product_terms);
       	$i = 0;
   
           foreach($product_terms as $term){
             echo '<a href="'.get_term_link($term->slug, 'skill').'">'.$term->name.'</a>';
       	  if (++$i != $numItems) {echo ', ';}
           }
   
         }
       }
       ?>
       ```
   
 *  Thread Starter [greencode](https://wordpress.org/support/users/greencode/)
 * (@greencode)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/wp_get_object_terms-comma-separated/#post-4101686)
 * Thanks so much for this. That works perfectly 🙂
 *  [Dibakar Jana](https://wordpress.org/support/users/themepurpose/)
 * (@themepurpose)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/wp_get_object_terms-comma-separated/#post-4101846)
 * Thanks [@greendemiurge](https://wordpress.org/support/users/greendemiurge/). 
   This worked nicely.!!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘wp_get_object_terms comma separated’ is closed to new replies.

## Tags

 * [wp_get_object_terms](https://wordpress.org/support/topic-tag/wp_get_object_terms/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [Dibakar Jana](https://wordpress.org/support/users/themepurpose/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/wp_get_object_terms-comma-separated/#post-4101846)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
