Title: Adding separator with wp-get-post-terms
Last modified: August 19, 2016

---

# Adding separator with wp-get-post-terms

 *  Resolved [jzk](https://wordpress.org/support/users/jzk/)
 * (@jzk)
 * [16 years ago](https://wordpress.org/support/topic/adding-separator-with-wp-get-post-terms/)
 * Hello,
 * In order to display the categories and child categories of each post, I am using
   this script (find there: [http://wordpress.org/support/topic/390397?replies=9](http://wordpress.org/support/topic/390397?replies=9)):
 *     ```
       <?php
       $args=array('orderby' => 'none');
       $terms = wp_get_post_terms( $post->ID , 'category', $args);
       foreach($terms as $term) {
         echo '<a href="' . esc_attr(get_term_link($term, 'category')) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name.'</a> ';
       }
       ?>
       ```
   
 * I want to add properly a separator, any ideas ?
 * Thanks!

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years ago](https://wordpress.org/support/topic/adding-separator-with-wp-get-post-terms/#post-1520401)
 * If you used something like:
 * `echo '<a class="mycatlist" href="' . esc_attr(get_term_link($term, 'category')).'"
   title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' .
   $term->name.'</a> ';`
 * you could then add a border-separator using CSS:
 * `.mycatlist {border-bottom:1px solid #999;}`
 *  Thread Starter [jzk](https://wordpress.org/support/users/jzk/)
 * (@jzk)
 * [16 years ago](https://wordpress.org/support/topic/adding-separator-with-wp-get-post-terms/#post-1520404)
 * Thanks for this answer.
 * It could be a way but ideally I would like to separate the category like this:
   
   cat-name_1 + cat-name_2 + cat-name3
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years ago](https://wordpress.org/support/topic/adding-separator-with-wp-get-post-terms/#post-1520406)
 * Do you literally want to add a “+” sign between each link? Or have I misunderstood?
 *  Thread Starter [jzk](https://wordpress.org/support/users/jzk/)
 * (@jzk)
 * [16 years ago](https://wordpress.org/support/topic/adding-separator-with-wp-get-post-terms/#post-1520410)
 * Yes I want literally add a “+” or “//” between each link.
    There is a way adding
   like that : `echo '<a href="' . esc_attr(get_term_link($term, 'category')) . '"
   title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' .
   $term->name.'</a> + ';`
 * But after the result is :
    cat-name_1 + cat-name_2 + cat-name3 +
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years ago](https://wordpress.org/support/topic/adding-separator-with-wp-get-post-terms/#post-1520411)
 * Try:
 *     ```
       <?php
       $args=array('orderby' => 'none');
       $terms = wp_get_post_terms( $post->ID , 'category', $args);
       $t = count($terms);
       $c = 0;
       foreach($terms as $term) {
         $c++;
         echo '<a href="' . esc_attr(get_term_link($term, 'category')) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name.'</a> ';
         if($c < $t ) echo ' + ';
       }
       ?>
       ```
   
 *  Thread Starter [jzk](https://wordpress.org/support/users/jzk/)
 * (@jzk)
 * [16 years ago](https://wordpress.org/support/topic/adding-separator-with-wp-get-post-terms/#post-1520416)
 * Great it works ! Really thanks a lot ! 😉
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years ago](https://wordpress.org/support/topic/adding-separator-with-wp-get-post-terms/#post-1520421)
 * Cool! Glad to have helped.

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

The topic ‘Adding separator with wp-get-post-terms’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 2 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [16 years ago](https://wordpress.org/support/topic/adding-separator-with-wp-get-post-terms/#post-1520421)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
