How to simply read your wordpress RSS feed in PHP

To get a date of a last post published in your blog:

<!--?php
$url_pblog = "http://liveexpert.pl/oskarj/feed/";
$rss = simplexml_load_file($url_pblog);
$lastpubdate = $rss--->channel->lastBuildDate;
$resultVx = preg_split('/\s/', $lastpubdate);
$newarray = array_slice($resultVx, 0, -1);
echo join(' ', $newarray)
?>

Just insert into variable $url_pblog the URL of your RSS feed, and off you go.

This code uses simplexml_load_file function(), and there are couple of alternatives to this solution.  RSS is still a proper-constructed XML file so any other parsers will be just fine.

Advertisements