How to simply read your wordpress RSS feed in PHP

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

$url_pblog = "";
$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.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

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

Google+ photo

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

Twitter picture

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

Facebook photo

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


Connecting to %s