wppaste
WordPress

get_term_feed_link( int|WP_Term|object $term, string $taxonomy = '', string $feed = '' ): string|false

Since
3.0.0
Source
wp-includes/link-template.php:935
Retrieves the feed link for a term.

Description

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

$termint|WP_Term|object
The ID or term object whose feed link will be retrieved.
$taxonomystringoptional
Taxonomy of $term_id.Default: ''
$feedstringoptional
Feed type. Possible values include 'rss2', 'atom'. Default is the value of get_default_feed().Default: ''

Return

string|false
Link to the feed for the term specified by $term and $taxonomy.

Hooks fired · 3

3 hooks fire while get_term_feed_link() runs, in this order:

  1. apply_filters( category_feed_link )filterline 983 (+48 into the body)

    Filters the category feed link.

  2. apply_filters( tag_feed_link )filterline 993 (+58 into the body)

    Filters the post tag feed link.

  3. apply_filters( taxonomy_feed_link )filterline 1004 (+69 into the body)

    Filters the feed link for a taxonomy other than 'category' or 'post_tag'.

Uses · 10

Used by · 4

Source

function get_term_feed_link( $term, $taxonomy = '', $feed = '' ) {	if ( ! is_object( $term ) ) {		$term = (int) $term;	} 	$term = get_term( $term, $taxonomy ); 	if ( empty( $term ) || is_wp_error( $term ) ) {		return false;	} 	$taxonomy = $term->taxonomy; 	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->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, $term->taxonomy );		if ( get_default_feed() === $feed ) {			$feed_link = 'feed';		} else {			$feed_link = "feed/$feed";		} 		$link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' );	} 	if ( 'category' === $taxonomy ) {		/**		 * Filters the category feed link.		 *		 * @since 1.5.1		 *		 * @param string $link The category feed link.		 * @param string $feed Feed type. Possible values include 'rss2', 'atom'.		 */		$link = apply_filters( 'category_feed_link', $link, $feed );	} elseif ( 'post_tag' === $taxonomy ) {		/**		 * Filters the post tag feed link.		 *		 * @since 2.3.0		 *		 * @param string $link The tag feed link.		 * @param string $feed Feed type. Possible values include 'rss2', 'atom'.		 */		$link = apply_filters( 'tag_feed_link', $link, $feed );	} else {		/**		 * Filters the feed link for a taxonomy other than 'category' or 'post_tag'.		 *		 * @since 3.0.0		 *		 * @param string $link     The taxonomy feed link.		 * @param string $feed     Feed type. Possible values include 'rss2', 'atom'.		 * @param string $taxonomy The taxonomy name.		 */		$link = apply_filters( 'taxonomy_feed_link', $link, $feed, $taxonomy );	} 	return $link;}

History

Introduced in 3.0.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 tag, from src/wp-includes/link-template.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.