获取某个作者的Feed订阅网址
返回给定作者所有文章的feed链接。为获取默认链接。可请求指定feed或将留空白。
用法
<?php get_author_feed_link( $author_id, $feed ) ?>
参数
$author_id
(integer) (必填) ID of an author.
默认值: None
$feed
(string) (可选) Feed type.
默认值: ”
返回值
(string)
Link to the feed for the author specified by $author_id.
示例
Default Usage
Returns the rss2 feed link for post by author 2.
<?php get_author_feed_link(‘2’, ”); ?>
历史
添加于 版本: 2.5.0
源文件
get_author_feed_link() 函数的代码位于 wp-includes/link-template.php
.
* Retrieve the feed link for a given author.
*
* 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.
*
* @since 2.5.0
*
* @param int $author_id ID of an author.
* @param string $feed Optional. Feed type.
* @return string Link to the feed for the author specified by $author_id.
*/
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’);
}
/**
* Filter 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;
}
原文:http://codex.wordpress.org/Function_Reference/get_author_feed_link