如何通过RSS从另一个Wordpress博客获取自定义字段


Wordpress - How to get a custom field from another wordpress blog via RSS

我需要通过RSS从另一个Wordpress博客导入一些内容到我的博客。目标博客包含一些需要导入的自定义字段(如:number_of_users)。我目前使用fetch_feed函数导入RSS提要,我不知道如何获得这些自定义字段的值。

下面是我使用的代码:
<?php if(function_exists('fetch_feed')) {
    // include the required file
    $feed = fetch_feed('http://domaintoimportfeedfrom.com/feed/'); // specify the source feed
    $limit = $feed->get_item_quantity(7); // specify number of items
    $items = $feed->get_items(0, $limit); // create an array of items
}
if ($limit == 0) echo '<div>The feed is either empty or unavailable.</div>';
else foreach ($items as $item) : ?>
<div>
    <a href="<?php echo $item->get_permalink(); ?>" 
      title="<?php echo $item->get_date('j F Y @ g:i a'); ?>">
        <?php echo $item->get_title(); ?>
    </a>
    // need to get the "number_of_users" custom field
</div>
<?php endforeach; ?>

请建议。

<?php
function getFeed($feed_url) {
  $content = file_get_contents($feed_url);
  $x = new SimpleXmlElement($content);
  echo "<ul>";
  foreach($x->channel->item as $entry) {
    echo "<li><a href='$entry->link' title='$entry->title'>" . $entry->title . "</a></li>";
  }
  echo "</ul>";
}
?>
<?php getFeed("http://domaintoimportfeedfrom.com/feed/"); ?>

http://code.tutsplus.com/articles/how - -读-一个rss提要-与- php -视频-网- 1272