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 totrue
to print the RSS link orfalse
to return it. Default isfalse
.$author_id
(int) (optional) – The ID of the author for whom you want to get the RSS feed link. Default is1
.
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
Get the RSS feed link for author with ID 2
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 );
Display the RSS feed link for author with ID 3
Print the RSS feed link for the author with ID 3.
get_author_rss_link( true, 3 );
Get RSS feed link for the current author in the loop
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 );
Display the RSS feed link for the current author in the loop
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 );
Get the RSS feed link for the author with ID 5 and use it in an HTML link
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>';