get_author_feed_link() WordPress Function

The get_author_feed_link() function in WordPress allows you to easily create an RSS feed for an author's posts. This is useful if you want to syndicate an author's content on your site, or if you want to allow readers to subscribe to an author's posts via RSS.

get_author_feed_link( int $author_id, string $feed = '' ) #

Retrieves the feed link for a given author.


Description

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


Top ↑

Parameters

$author_id

(int)(Required)Author ID.

$feed

(string)(Optional) Feed type. Possible values include 'rss2', 'atom'. Default is the value of get_default_feed().

Default value: ''


Top ↑

Return

(string) Link to the feed for the author specified by $author_id.


Top ↑

Source

File: wp-includes/link-template.php

function get_author_feed_link( $author_id, $feed = '' ) {
	$author_id           = (int) $author_id;
	$permalink_structure = get_option( 'permalink_structure' );

	if ( empty( $feed ) ) {
		$feed = get_default_feed();
	}

	if ( ! $permalink_structure ) {
		$link = home_url( "?feed=$feed&author=" . $author_id );
	} else {
		$link = get_author_posts_url( $author_id );
		if ( get_default_feed() == $feed ) {
			$feed_link = 'feed';
		} else {
			$feed_link = "feed/$feed";
		}

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

	/**
	 * Filters the feed link for a given author.
	 *
	 * @since 1.5.1
	 *
	 * @param string $link The author feed link.
	 * @param string $feed Feed type. Possible values include 'rss2', 'atom'.
	 */
	$link = apply_filters( 'author_feed_link', $link, $feed );

	return $link;
}


Top ↑

Changelog

Changelog
VersionDescription
2.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More