WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Самая быстрая Тема-конструктор для WordPress
функция не описана

get_term_feed_link() WP 3.0.0

Retrieves 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.

Возвращает

Строку/false. Link to the feed for the term specified by $term_id and $taxonomy.

Использование

get_term_feed_link( $term_id, $taxonomy, $feed );
$term_id(число) (обязательный)
Term ID.
$taxonomy(строка)
Taxonomy of $term_id.
По умолчанию: 'category'
$feed(строка)
Feed type. Possible values include 'rss2', 'atom'.
По умолчанию: value of get_default_feed()

Список изменений

С версии 3.0.0 Введена.

Код get_term_feed_link() WP 5.5.1

<?php
function get_term_feed_link( $term_id, $taxonomy = 'category', $feed = '' ) {
	$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&amp;cat=$term_id" );
		} elseif ( 'post_tag' === $taxonomy ) {
			$link = home_url( "?feed=$feed&amp;tag=$term->slug" );
		} else {
			$t    = get_taxonomy( $taxonomy );
			$link = home_url( "?feed=$feed&amp;$t->query_var=$term->slug" );
		}
	} else {
		$link = get_term_link( $term_id, $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;
}