2
我对RSS提要有疑问。我正在使用wordpress ver 3.2.1并在我的网站中使用其他网站rss feed。我的要求是明智地获取Feed,并在我的网站侧栏中显示。如何从其他网站获取月明智的rss feed
目前我使用的RSS窗口小部件,并显示在侧边栏的饲料,但他们在下面的格式进来:
- 9-29星期四下午4:30基本任务 - 家长信息夜
- 周四10-6 - 全天 - 半天:小学会议
我会非常感谢您的帮助。提前致谢。
更新: 2012年3月13日
此代码出现在的index.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('http://example.com/rss/feed/goes/here');
$rss = fetch_feed('http://lakewashington.intand.com/index.php?type=export&action=rss&schools=48&groups=884,876,874,996');
print_r($rss);
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(5);
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items(0, $maxitems);
endif;
?>
<ul>
<?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 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>
</li>
<?php endforeach; ?>
</ul>
亲爱的TCattd,首先我想说感谢您关注我的问题。我错了 - 最近的新闻来自Some-Other博客: WP_Error Object([errors] => Array([simplepie-error] => Array([0] => WP HTTP错误:无法打开fopen()到http://lakewashington.intand.com/index.php?type=export&action=rss&schools=48&groups=884,876,874,996))[error_data] => Array()) *没有项目。 – w3uiguru
你能粘贴你使用的整个代码吗? – TCattd
检查我更新的代码。 – w3uiguru