function fetch_feed($url) {}

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


  • string $url: URL to retrieve feed

Return values

returns:WP_Error object on failure or SimplePie object on success

Defined filters

  • wp_feed_cache_transient_lifetime
    apply_filters('wp_feed_cache_transient_lifetime', 43200, $url)

Defined actions

  • wp_feed_options
    do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) );

Source code

function fetch_feed($url) {

	require_once (ABSPATH . WPINC . '/class-feed.php');

	$feed = new SimplePie();




	$feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 43200, $url));

	do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) );



	if ( $feed->error() )

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

	return $feed;



No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: