Nos Offres Sur Autoscout

function vp_get_rss_feed($feed_url) {
$expires = 7200; // 2hours

delete_transient( ‘rss_bbc_feed_world’ );
$feed = get_transient( ‘rss_bbc_feed_world’ );
if ( false === ( $rss = $feed ) ) :
$rss = new DOMDocument();
$rss->load($feed_url);

$feed = array();
$i=1;
foreach ($rss->getElementsByTagName(‘item’) as $node) {

$link = $node->getElementsByTagName(‘link’)->item(0)->nodeValue;
$title = $node->getElementsByTagName(‘title’)->item(0)->nodeValue;
$slug = sanitize_title($title);
$desc = $node->getElementsByTagName(‘description’)->item(0)->nodeValue;

$item[$slug] = array (
‘title’ => $title,
‘slug’ => $slug,
‘desc’ => $desc,
‘date’ => $node->getElementsByTagName(‘pubDate’)->item(0)->nodeValue,
);

}
array_push( $feed, $item );
set_transient( ‘rss_bbc_feed_world’, $feed, $expires );
endif;
return $feed;
}

Back to top