Advertisement
rakeshr

list parent term first and then child

Nov 14th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. <?php
  2.  
  3. $taxonomy = 'albo_regioni';
  4.  
  5. // get the term IDs assigned to post.
  6. $post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
  7. // separator between links
  8. $separator = ', ';
  9.  
  10. if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) {
  11.  
  12.     $term_ids = implode( ',' , $post_terms );
  13.     $terms = wp_list_categories( 'title_li=&style=none&echo=0&taxonomy=' . $taxonomy . '&include=' . $term_ids );
  14.     $terms = rtrim( trim( str_replace( '<br />',  $separator, $terms ) ), $separator );
  15.  
  16.     // display post categories
  17.     echo  $terms;
  18. }
  19.  
  20.  
  21.             ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement