我使用fetch\\u feed(基于Simplepie)来显示一系列RSS feed(仅限于favicon和headlines)。有关simplepie website 表示在样式表中使用get\\u favicon。我用的是fetch_feed codex 实例我得到了favicon应该在哪里的间距,但不是favicon。馈送链接看起来很好。
CSS:
.rss a {
padding:0 0 0 20px;
background:transparent url(<?php echo esc_url ( $item->get_favicon() ); ?>) no-repeat 0 1px;
}
PHP:<h2><?php _e(\'Recent news from Some-Other Blog:\'); ?></h2>
<?php // Get RSS Feed(s)
// include_once(ABSPATH . WPINC . \'/feed.php\');
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed(array(\'http://wordpress.org/news/feed/\',\'http://beernews.org/feed/\'));
if (!is_wp_error( $rss ) ) : // Checks that the object is created correctly
// Figure out how many total items there are, but limit it to 5.
$maxitems = $rss->get_item_quantity(20);
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items(0, $maxitems);
endif;
?>
<ul style="list-style-type: none;">
<?php if ($maxitems == 0) echo \'<li>No items.</li>\';
else
// Loop through each feed item and display each item as a hyperlink.
foreach ( $rss_items as $item ) : ?>
<li>
<a class=\'rss\' href=\'<?php echo esc_url( $item->get_permalink() ); ?>\' title=\'<?php echo \'Posted \'.$item->get_date(\'j F Y | g:i a\'); ?>\'>
<?php echo esc_html( $item->get_title() ); ?>
</a>
<?php echo \'<hr/>\'; ?>
</li>
<?php endforeach; ?>
</ul>