• I wanted to display an External RSS from mybb forum to my wordpress blog. I found out the function fetch feed (http://codex.wordpress.org/Function_Reference/fetch_feed). According to the codex page this function uses SimplePie and FeedCache functionality to retrieve, parse and cache an external feed. My blog is hosted on a shared server and I am worried about server overload. So I wanted to find out when the cache expires. The SimplePie documentation tells that cache expires after every 60 mins. Now the extrenal feed I want to display does not change more than once or twice a day. So how could I change these 60 mins to 180 mins.

    Secondly, the fetch_feed page describes a method to display 5 items from a feed. But mybb forum’s syndication could be queried for number of items like this http://www.example.com/forum/syndication.php?limit=5 so I basically don’t need to check the items. So how do I change the code so that it doesn’t check the number of items in the feed. Below is the Fetch_Feed example from codex.

    <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');
    
    // 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);
    ?>
    
    <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 $item->get_permalink(); ?>'
            title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>'>
            <?php echo $item->get_title(); ?></a>
        </li>
        <?php endforeach; ?>
    </ul>

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fetch_Feed : How Can I change the Cache Time’ is closed to new replies.