我正在使用SimplePie在Wordpress中显示RSS提要。出于某种原因,get_date函数什么都没有返回?这是我下面的代码。这可能是我的Feed的问题吗?
<h3><span class="dark-blue">news</span> & media</h3>
<ul>
<?php $feed = fetch_feed( 'http://dgpp.ie/dgppnews_rss.xml' );
foreach ( $feed->get_items() as $item ) {
printf( '<li><a href="%s"><strong>%s</strong></a>', $item->get_permalink(),
$item->get_title() );
printf( '<p>%s</p>', $item->get_description() );
printf( '<p>%s</p>', $item->get_date() );
printf( '<a href="%s" class="readmore">read more</a></li>', $item->get_permalink() );
}
?>
</ul>
答案 0 :(得分:0)
我对http://simplepie.org/wiki/setup/sample_page做了快速检查,这对我有用:
<?php
require_once('php/simplepie.inc');
$feed = new SimplePie();
$feed->set_feed_url('http://dgpp.ie/dgppnews_rss.xml');
$feed->init();
?>
<h3><span class="dark-blue">news</span> & media</h3>
<ul>
<?php
foreach ( $feed->get_items() as $item ) {
printf( '<li><a href="%s"><strong>%s</strong></a>', $item->get_permalink(),
$item->get_title() );
printf( '<p>%s</p>', $item->get_description() );
printf( '<p>%s</p>', $item->get_date() );
printf( '<a href="%s" class="readmore">read more</a></li>', $item->get_permalink() );
}
?>
</ul>
<?php
require_once('php/simplepie.inc');
$feed = new SimplePie();
$feed->set_feed_url('http://dgpp.ie/dgppnews_rss.xml');
$feed->init();
?>
<h3><span class="dark-blue">news</span> & media</h3>
<ul>
<?php
foreach ( $feed->get_items() as $item ) {
printf( '<li><a href="%s"><strong>%s</strong></a>', $item->get_permalink(),
$item->get_title() );
printf( '<p>%s</p>', $item->get_description() );
printf( '<p>%s</p>', $item->get_date() );
printf( '<a href="%s" class="readmore">read more</a></li>', $item->get_permalink() );
}
?>
</ul>