get_rss
函数
get_rss ( $url, $num_items = 5 )
- 参数
-
-
(string)
$url
URL of feed to display. Will not auto sense feed URL.- Required: 是
-
(int)
$num_items
Optional. Number of items to display, default is all.- Required: 否
- Default: 5
-
(string)
- 返回值
-
- (bool) False on failure.
- 定义位置
-
-
wp-includes/rss.php
, line 932
-
wp-includes/rss.php
- 引入
- 1.5.0
- 弃用
- –
Display RSS items in HTML list items.
You have to specify which HTML list you want, either ordered or unordered
before using the function. You also have to specify how many items you wish
to display. You can’t display all of them like you can with wp_rss()
function.
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 "
echo “”;
echo esc_html($item[‘title’]);
echo “
n”;
echo “
n”;
}
} else {
return false;
}
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。