135
include_once(ABSPATH . WPINC . '/feed.php'); if(function_exists('fetch_feed')) { $feed = fetch_feed('http://website-of-content.com/content.rss'); // this is the external website's RSS feed URL if (!is_wp_error($feed)) : $feed->init(); $feed->set_output_encoding('UTF-8'); // this is the encoding parameter, and can be left unchanged in almost every case $feed->handle_content_type(); // this double-checks the encoding type $feed->set_cache_duration(21600); // 21,600 seconds is six hours $limit = $feed->get_item_quantity(18); // fetches the 18 most recent RSS feed stories $items = $feed->get_items(0, $limit); // this sets the limit and array for parsing the feed endif; }
// This block of code creates the first column of six RSS feed items $blocks = array_slice($items, 0, 6); // Items zero through six will be displayed here foreach ($blocks as $block) { echo $block->get_title(); echo $block->get_description(); } // This block of code creates the second column of six RSS feed items $blocks = array_slice($items, 6, 12); // Items seven through twelve are placed in the second column foreach ($blocks as $block) { echo $block->get_title(); echo $block->get_description(); } // This block of code creates the third column of six RSS feed items $blocks = array_slice($items, 12, 18); // Feed items thirteen through eighteen go in the third column foreach ($blocks as $block) { echo $block->get_title(); echo $block->get_description(); }
$blocks = array_slice($items, 0, 6); // Items zero through six will be displayed here
<?php echo $block->get_date("m d Y"); ?>
<div class="rss-column-story"> <h3><?php echo $block->get_title(); ?></a></h3> <p/> <?php echo $block->get_date("m d Y"); ?> <?php echo substr($block->get_description() ?> <a href="<?php echo $block->get_permalink(); ?>">More...</a> </div>
if ($limit == 0) { echo 'News is currently not available due to server issues. Check back soon!'; } else { SLICE CODE GOES HERE }
热门分享
最新文章
2019.08.16
东城网页设计:Web设计中令人印象深刻的案例研究示例
2019.08.16
东城企业网站建设:有助于改善结帐转化的提示
2019.08.16
东城网站开发:15个响应式jQuery UI代码段和模块
2019.08.16
东城网站制作:移动设备的热门数据和内容设计模式
2019.08.16
东城网站建设:为可读性设计网站文本
2019.05.27
东城企业网站开发:30幅令人惊叹的机器人插图
2019.05.27
东城网页设计:如何在WordPress中将RSS提要解析为内容
2019.05.27
东城公司网站制作:如何创建WordPress自定义选项页
2019.05.27
东城企业做网站:有效启动WordPress插件的技巧
2019.05.27
东城公司网站开发:掌握HTML 5文件API
随机推荐
2019.08.16
东城网站建设:为可读性设计网站文本
2019.05.27
东城公司网站开发:掌握HTML 5文件API
2019.05.27
东城做网站:用jQuery编写VimeoAPI即时搜索应用程序
2019.08.16
东城网页设计:Web设计中令人印象深刻的案例研究示例
2019.05.27
东城企业做网站:有效启动WordPress插件的技巧
2019.05.27
东城公司网站制作:如何创建WordPress自定义选项页
2019.05.27
东城网页设计:如何在WordPress中将RSS提要解析为内容
2019.08.16
东城网站开发:15个响应式jQuery UI代码段和模块
2019.08.16
东城网站制作:移动设备的热门数据和内容设计模式
2019.05.27
东城企业网站开发:30幅令人惊叹的机器人插图