Using WordPress ‘get_author_rss_link()’ PHP function

The get_author_rss_link() WordPress PHP function retrieves the RSS feed link for a specific author.

Usage

get_author_rss_link( $display, $author_id );

Input:

  • $display (bool) (optional) – Set to true to print the RSS link or false to return it. Default is false.
  • $author_id (int) (optional) – The ID of the author for whom you want to get the RSS feed link. Default is 1.

Output:

  • The RSS feed link for the specified author.

Parameters

  • $display (bool) – Determines whether to print or return the RSS link.
  • $author_id (int) – The ID of the author for whom the RSS feed link should be retrieved.

More information

See WordPress Developer Resources: get_author_rss_link

Examples

Retrieve the RSS feed link for the author with ID 2 and store it in a variable.

$rss_link = get_author_rss_link( false, 2 );

Print the RSS feed link for the author with ID 3.

get_author_rss_link( true, 3 );

In a loop, retrieve the RSS feed link for the current author and store it in a variable.

$author_id = get_the_author_meta( 'ID' );
$rss_link = get_author_rss_link( false, $author_id );

In a loop, print the RSS feed link for the current author.

$author_id = get_the_author_meta( 'ID' );
get_author_rss_link( true, $author_id );

Retrieve the RSS feed link for the author with ID 5 and use it in an anchor tag.

$rss_link = get_author_rss_link( false, 5 );
echo '<a href="' . esc_url( $rss_link ) . '">Subscribe to author RSS</a>';