Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // get ID of the term "open" using it's slug from the taxonomy "resource_tag"
- $tag_open = get_term_by( 'slug', 'open', 'resource_tag' );
- // get ID of the term "home" using it's slug from the taxonomy "resource_tag"
- $tag_home = get_term_by( 'slug', 'home', 'resource_tag' );
- // add any other terms to exclude here ...
- // exclude category from term list by ID ##
- echo ql_get_the_term_list( get_the_ID(), 'resource_tag', '', ', ', '', array( $tag_open->term_id, $tag_home->term_id ) );
- // get term list with exclusion by ID ##
- function ql_get_the_term_list( $id = 0, $taxonomy, $before = '', $sep = '', $after = '', $exclude = array() ) {
- $exclude_string = implode ( ',', $exclude );
- $terms = get_terms( $taxonomy, array(
- 'exclude' => $exclude_string,
- ) );
- if ( is_wp_error( $terms ) )
- return $terms;
- if ( empty( $terms ) )
- return false;
- foreach ( $terms as $term ) {
- if( has_term( $term->name, $taxonomy ) ) { // filter by has_term() ##
- $link = get_term_link( $term, $taxonomy );
- if ( is_wp_error( $link ) )
- return $link;
- $term_links[] = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>';
- }
- }
- if ( $term_links ) {
- $term_links = apply_filters( "term_links-$taxonomy", $term_links );
- return $before . implode( $sep, $term_links ) . $after;
- } else {
- return 'None';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement