WordPress fetch_feed() - > get_items() - > get_another()

时间:2013-11-20 18:30:53

标签: php wordpress rss

我想通过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 
    }
}
?>

2 个答案:

答案 0 :(得分:1)

尝试get_item_tags()

get_item_tags( '', 'full-text' )

AFAIK full-text是一个非标准的Feed元素,因此SimplePie的方法无法处理它。

答案 1 :(得分:0)

一些简单的搜索引导我:

http://simplepie.org/wiki/reference/start#simplepie_item

您可以尝试使用get_Content();