Skip to content

Instantly share code, notes, and snippets.

Last active Dec 17, 2015
What would you like to do?
Instantiating a SimplePie object in WordPress
/* Create the SimplePie object */
$this->feed = new SimplePie();
/* Set the URL of the feed you're retrieving */
$this->feed->set_feed_url( $this->source );
/* Tell SimplePie to cache the feed using WordPress' cache class */
$this->feed->set_cache_class( 'WP_Feed_Cache' );
/* Tell SimplePie to use the WordPress class for retrieving feed files */
$this->feed->set_file_class( 'WP_SimplePie_File' );
/* Tell SimplePie how long to cache the feed data in the WordPress database */
$this->feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 43200, $this->source ) );
/* Run any other functions or filters that WordPress normally runs on feeds */
do_action_ref_array( 'wp_feed_options', array( &$this->feed, $this->source ) );
/* Initiate the SimplePie instance */
/* Tell SimplePie to send the feed MIME headers */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment