Advertisements

get_term_feed_link

Definition:
function get_term_feed_link( $term_id, $taxonomy = 'category', $feed = '' ) {}

Retrieve the feed link for a term.
Returns a link to the feed for all posts in a given term. A specific feed can be requested or left blank to get the default feed.

Parameters

  • int $term_id: ID of a category.
  • string $taxonomy: Optional. Taxonomy of $term_id
  • string $feed: Optional. Feed type.

Return values

returns:Link to the feed for the term specified by $term_id and $taxonomy.

Defined filters

  • category_feed_link
    apply_filters( 'category_feed_link', $link, $feed )
  • category_feed_link
    apply_filters( 'category_feed_link', $link, $feed )
  • taxonomy_feed_link
    apply_filters( 'taxonomy_feed_link', $link, $feed, $taxonomy )

Source code

function get_term_feed_link( $term_id, $taxonomy = 'category', $feed = '' ) {

	global $wp_rewrite;



	$term_id = ( int ) $term_id;



	$term = get_term( $term_id, $taxonomy  );



	if ( empty( $term ) || is_wp_error( $term ) )

		return false;



	if ( empty( $feed ) )

		$feed = get_default_feed();



	$permalink_structure = get_option( 'permalink_structure' );



	if ( '' == $permalink_structure ) {

		if ( 'category' == $taxonomy ) {

			$link = home_url("?feed=$feed&cat=$term_id");

		}

		elseif ( 'post_tag' == $taxonomy ) {

			$link = home_url("?feed=$feed&tag=$term->slug");

		} else {

			$t = get_taxonomy( $taxonomy );

			$link = home_url("?feed=$feed&$t->query_var=$term->slug");

		}

	} else {

		$link = get_term_link( $term_id, $term->taxonomy );

		if ( $feed == get_default_feed() )

			$feed_link = 'feed';

		else

			$feed_link = "feed/$feed";



		$link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' );

	}



	if ( 'category' == $taxonomy )

		$link = apply_filters( 'category_feed_link', $link, $feed );

	elseif ( 'post_tag' == $taxonomy )

		$link = apply_filters( 'category_feed_link', $link, $feed );

	else

		$link = apply_filters( 'taxonomy_feed_link', $link, $feed, $taxonomy );





	return $link;

}

1757

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: