get_author_feed_link

Retrieves the feed link for a given author.

Description

(string) get_author_feed_link( (int) $author_id, (string) $feed = '' ); 

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

  1. if ( !function_exists( 'get_author_feed_link' ) ) { 
  2. require_once ABSPATH . WPINC . '/link-template.php'; 
  3.  
  4. // The author id. 
  5. $author_id = -1; 
  6.  
  7. // Optional. Feed type. Default empty. 
  8. $feed = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = get_author_feed_link($author_id, $feed); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/link-template.php  
  1. function get_author_feed_link( $author_id, $feed = '' ) { 
  2. $author_id = (int) $author_id; 
  3. $permalink_structure = get_option('permalink_structure'); 
  4.  
  5. if ( empty($feed) ) 
  6. $feed = get_default_feed(); 
  7.  
  8. if ( '' == $permalink_structure ) { 
  9. $link = home_url("?feed=$feed&author=" . $author_id); 
  10. } else { 
  11. $link = get_author_posts_url($author_id); 
  12. if ( $feed == get_default_feed() ) 
  13. $feed_link = 'feed'; 
  14. else 
  15. $feed_link = "feed/$feed"; 
  16.  
  17. $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); 
  18.  
  19. /** 
  20. * Filters the feed link for a given author. 
  21. * @since 1.5.1 
  22. * @param string $link The author feed link. 
  23. * @param string $feed Feed type. 
  24. */ 
  25. $link = apply_filters( 'author_feed_link', $link, $feed ); 
  26.  
  27. return $link;