Advertisements

get_the_term_list

Definition:
function get_the_term_list( $id = 0, $taxonomy, $before = '', $sep = '', $after = '' ) {}

Retrieve a post’s terms as a list with specified format.

Parameters

  • int $id: Post ID.
  • string $taxonomy: Taxonomy name.
  • string $before: Optional. Before list.
  • string $sep: Optional. Separate items using this.
  • string $after: Optional. After list.

Defined filters

  • term_links-$taxonomy
    apply_filters( "term_links-$taxonomy", $term_links )

Source code

function get_the_term_list( $id = 0, $taxonomy, $before = '', $sep = '', $after = '' ) {

	$terms = get_the_terms( $id, $taxonomy );



	if ( is_wp_error( $terms ) )

		return $terms;



	if ( empty( $terms ) )

		return false;



	foreach ( $terms as $term ) {

		$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;

}

1855

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: