get_author_feed_link
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.
Returns (string)
Link to the feed for the author specified by $author_id.
Parameters (2)
- 0. $author_id (int)
- The author id.
- 1. $feed — Optional. (string) =>
''
- Feed type. Default empty.
Usage
if ( !function_exists( 'get_author_feed_link' ) ) { require_once ABSPATH . WPINC . '/link-template.php'; } // The author id. $author_id = -1; // Optional. Feed type. Default empty. $feed = ''; // NOTICE! Understand what this does before running. $result = get_author_feed_link($author_id, $feed);
Defined (1)
The function is defined in the following location(s).
- /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 ( $feed == get_default_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.
- */
- $link = apply_filters( 'author_feed_link', $link, $feed );
- return $link;
- }