On this page
get_author_feed_link( int $author_id, string $feed = '' ): string
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.
Parameters
$author_idint Required-
Author ID.
$feedstring Optional-
Feed type. Possible values include
'rss2','atom'.
Default is the value of get_default_feed() .Default:
''
Return
string Link to the feed for the author specified by $author_id.
Source
File: wp-includes/link-template.php. View all references
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;
}
Hooks
- apply_filters( 'author_feed_link',
string $link ,string $feed ) -
Filters the feed link for a given author.
Related
Uses
| Uses | Description |
|---|---|
| user_trailingslashit() wp-includes/link-template.php | Retrieves a trailing-slashed string if the site is set for adding trailing slashes. |
| get_default_feed() wp-includes/feed.php | Retrieves the default feed. |
| get_author_posts_url() wp-includes/author-template.php | Retrieves the URL to the author page for the user with the ID provided. |
| trailingslashit() wp-includes/formatting.php | Appends a trailing slash. |
| home_url() wp-includes/link-template.php | Retrieves the URL for the current site where the front end is accessible. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
| get_option() wp-includes/option.php | Retrieves an option value based on an option name. |
Used By
| Used By | Description |
|---|---|
| wp_list_users() wp-includes/user.php | Lists all the users of the site, with several options available. |
| feed_links_extra() wp-includes/general-template.php | Displays the links to the extra feeds such as category feeds. |
| get_author_rss_link() wp-includes/deprecated.php | Print/Return link to author RSS feed. |
| wp_list_authors() wp-includes/author-template.php | Lists all the authors of the site, with several options available. |
Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_author_feed_link