Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




fetch_feed [ WordPress Function ]

fetch_feed ( $url )
Parameters:
  • (string) $url URL to retrieve feed
Returns:
  • (WP_Error|SimplePie) WP_Error object on failure or SimplePie object on success
Defined at:



Build SimplePie object based on RSS or Atom feed from URL.

Source


<?php
function fetch_feed($url) {
    require_once (
ABSPATH WPINC '/class-feed.php');

    
$feed = new SimplePie();
    
$feed->set_feed_url($url);
    
$feed->set_cache_class('WP_Feed_Cache');
    
$feed->set_file_class('WP_SimplePie_File');
    
$feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime'43200$url));
    
do_action_ref_array'wp_feed_options', array( &$feed$url ) );
    
$feed->init();
    
$feed->handle_content_type();

    if ( 
$feed->error() )
        return new 
WP_Error('simplepie-error'$feed->error());

    return 
$feed;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

1 User Note(s)

Gravatar
All feeds are cached in the wp_options table when the fetch_feed function is used, is there a way to cache it in a file like simplepie does.

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics