Created
March 12, 2014 22:39
-
-
Save yratof/9518025 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$taxonomy = 'category'; | |
// get the term IDs assigned to post. | |
$post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); | |
// separator between links | |
$separator = ', '; | |
if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) { | |
$term_ids = implode( ',' , $post_terms ); | |
$terms = wp_list_categories( 'title_li=&style=none&echo=0&taxonomy=' . $taxonomy . '&include=' . $term_ids ); | |
$terms = rtrim( trim( str_replace( '<br />', $separator, $terms ) ), $separator ); | |
// display post categories | |
echo $terms; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment