函数原型
get_rss( string $url, int $num_items = 5 ): bool
函数描述
Display RSS items in HTML list items.
是否弃用
未弃用
函数参数
-
$url
string
Required - URL of feed to display. Will not auto sense feed URL.
-
$num_items
int
Optional - Number of items to display, default is all.
Default:
5
函数返回值
bool False on failure.
函数位置
File: wp-includes/rss.php.
函数源码
function get_rss ($url, $num_items = 5) { // Like get posts, but for RSS
$rss = fetch_rss($url);
if ( $rss ) {
$rss->items = array_slice($rss->items, 0, $num_items);
foreach ( (array) $rss->items as $item ) {
echo "<li>\n";
echo "<a href='$item[link]' title='$item[description]'>";
echo esc_html($item['title']);
echo "</a><br />\n";
echo "</li>\n";
}
} else {
return false;
}
}
源码链接
变更日志
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |

