wp_rss
函数
wp_rss ( $url, $num_items = -1 )
- 参数
-
-
(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: -1
-
(string)
- 定义位置
-
-
wp-includes/rss.php
, line 891
-
wp-includes/rss.php
- 引入
- 1.5.0
- 弃用
- –
Display all RSS items in a HTML ordered list.
function wp_rss( $url, $num_items = -1 ) { if ( $rss = fetch_rss( $url ) ) { echo '
- ‘;
- %3$s
if ( $num_items !== -1 ) {
$rss->items = array_slice( $rss->items, 0, $num_items );
}
foreach ( (array) $rss->items as $item ) {
printf(
‘
‘,
esc_url( $item[‘link’] ),
esc_attr( strip_tags( $item[‘description’] ) ),
esc_html( $item[‘title’] )
);
}
echo ‘
‘;
} else {
_e( ‘An error has occurred, which probably means the feed is down. Try again later.’ );
}
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。