Forums

Parsing multiple feeds by fetch_rss (3 posts)

  1. alvanweb
    Member
    Posted 11 months ago #

    Hi
    I need to parse multiple feeds by fetch_rss function. Feeds get from link_rss column in wp_links table. Code that I write here:

    include_once(ABSPATH . WPINC . '/rss.php');
    function rss_fetching (){
    	global $wpdb;
    	$feeds_url = $wpdb->get_col("SELECT link_rss FROM $wpdb->links");
    	foreach ($feeds_url as $url){
    		$rss = fetch_rss($url);
    
    		$maxitems = 1; //Number of display items in each feed
    		$items = array_slice($rss->items, 0, $maxitems);
    		echo '<ul>';
    		if (empty($items)){
    			echo '<li>No items</li>';
    		} else {
    			foreach ( $items as $item ) {
    				echo "<li><a href=\"".$item['link']."\" title=\"".$item['description']."\">".$item['title']."</a></li>";
    			}
    		}
    		echo '</ul>';
    	}
    }

    First Q:
    This code work exactly but decrease page loading speed! Fetching feeds repeat in each refresh. I know fetch_rss is related with MagpieRSS class. How I can use RSSCache of this class to remove fetching repeat?! Or maybe my code is wrong! because with one feed it
    Work correctly and maybe used cash system of this class!

    Second Q:
    How I can get items date?

  2. alvanweb
    Member
    Posted 11 months ago #

    Posted 1 day ago!
    nobody help me?

  3. whoisvaibhav
    Member
    Posted 4 months ago #

    $item['pubdate']

Reply

You must log in to post.

About this Topic