May 26, 2015
function my_get_the_term_list( $id = 0, $taxonomy, $before = '', $sep = '', $after = '', $exclude = array() ) {
$terms = get_the_terms( $id, $taxonomy );
if ( is_wp_error( $terms ) )
return $terms;
if ( empty( $terms ) )
return false;
foreach ( $terms as $term ) {
if(!in_array($term->term_id,$exclude)) {
$link = get_term_link( $term, $taxonomy );
if ( is_wp_error( $link ) )
return $link;
$term_links[] = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>';
}
}
$term_links = apply_filters( "term_links-$taxonomy", $term_links );
return $before . join( $sep, $term_links ) . $after;
}
Place the above code inside of functions.php and wherever needed add the following into your template files:
<p>Posted in <?php echo my_get_the_term_list( $post->ID, 'your-category-name', '', ' ', '', array(18) ); ?> By <?php the_author(); ?></p>
Update with the relevant category name, and remember to include the IDs for the categories you wish to exclude.
Sourced here.