我想通过RSS结构将新闻导入我的WordPress网站:
<item>
<title>...title...</title>
<link>..link...</link>
<description>...short description...</description>
<full-text>...full-text...</full-text>
<enclosure url="http://.../post_image123.jpg" type="image/jpeg"/>
<category>...category...</category>
<pubDate>Wed, 20 Nov 2013 17:32:41 +0400</pubDate>
</item>
我知道如何获取除full-text
之外的所有标记,而我没有找到任何关于此的文档。我如何获得full-text
?
代码:
<?php
$rsslist = array(
'http://kavkazinfo.net/backend.php?region=%C4%E0%E3%E5%F1%F2%E0%ED',
'http://kavkazinfo.net/backend.php?region=%C8%E7%F0%E0%E8%EB%FC',
);
// Fetch all of the feeds into a simplePie mashup
$rss = fetch_feed($rsslist);
// Set the max items to either 5 or all items if there are less than 10
$maxitems = $rss->get_item_quantity(5);
// Get the items (0-5)
$rss_items = $rss->get_items(0, $maxitems);
// If there are no items, output that
if ($maxitems == 0) {
echo '<li>No items.</li>';
// Otherwise loop over the items
} else {
foreach ($rss_items as $item) { ?>
<li>
<?php echo $item->get_fulltext(); ?> // Of course, get_fulltext() doesn't exist as a function, so how do I get it?
</li>
<?php
}
}
?>
答案 0 :(得分:1)
get_item_tags( '', 'full-text' )
AFAIK full-text
是一个非标准的Feed元素,因此SimplePie的方法无法处理它。
答案 1 :(得分:0)