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
定义位置
  • wp-includes/rss.php
    , line 891
引入
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 '
    ‘;

    if ( $num_items !== -1 ) {
    $rss->items = array_slice( $rss->items, 0, $num_items );
    }

    foreach ( (array) $rss->items as $item ) {
    printf(

  • %3$s
  • ‘,
    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.’ );
}
}