Best way to grab and display an RSS feed every once in a while
-
Which method is best for periodically scraping an RSS feed? using the fetch_rss function or using the inlineRSS plugin?
Right now I have a demo site (sorry it’s on my Mac locally so no links) set up with the fetch_rss function on a page and it works(!). Is it fetching the rss each time someone clicks? Is there anyway to set it so it only grabs the RSS every 8 or 12 hours?
here’s what the template says:
<?php
/*
Template Name: rss-listing
Description: A template for scraping an rss feed.
*/
?>
<?php get_header(); ?>
<div id="content" class="narrowcolumn">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<div class="entry">
<p>some text</p>
<?php require_once(ABSPATH . WPINC . '/rss-functions.php'); ?>
<?php $rss = fetch_rss('some-uri'); ?>
<ul class="rss-listing">
<?php foreach ( $rss->items as $item ) : ?>
<li><?php echo $item['image_link']; ?>
<a href='<?php echo $item['link']; ?>
title='<?php echo $item['title']; ?>'>
<?php echo $item['title']; ?>
</a>
<?php echo $item['description']; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endwhile; endif; ?>
<?php edit_post_link('Edit this entry.', '', '
'); ?>
</div>
rss
<?php get_sidebar(); ?>
<?php get_footer(); ?>
I’m not a coder, just an amateur, so if anyone can help that would be great. Specific detailed step-by-step instructions would be awesome!
- The topic ‘Best way to grab and display an RSS feed every once in a while’ is closed to new replies.