Using WordPress ‘get_author_feed_link()’ PHP function

The get_author_feed_link() WordPress PHP function retrieves the feed link for a given author.

Usage

To use the function, provide the author’s ID and an optional feed type:

get_author_feed_link($author_id, $feed);

Example:

echo get_author_feed_link(2, 'rss2');

Output:

https://example.com/author/johndoe/feed/

Parameters

  • $author_id (int): Required. The author’s ID.
  • $feed (string): Optional. Feed type. Possible values include ‘rss2’, ‘atom’. Default is the value of get_default_feed().

More information

See WordPress Developer Resources: get_author_feed_link()

Examples

Get the default feed link for author with ID 3:

echo get_author_feed_link(3);

Get the RSS2 feed link for author with ID 4:

echo get_author_feed_link(4, 'rss2');

Get the Atom feed link for author with ID 5:

echo get_author_feed_link(5, 'atom');

Display the feed link for author with ID 6 in an HTML anchor tag:

echo '<a href="' . get_author_feed_link(6) . '">Subscribe to Author Feed</a>';

Get the feed link for an author with a dynamic ID and feed type:

$author_id = 7;
$feed_type = 'rss2';
echo get_author_feed_link($author_id, $feed_type);