How do I take an RSS feed from wordpress.com and add the newest post of the feed to another website? [closed]
Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Over开发者_如何转开发flow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this questionI am building a static site using php files. On the index.php file, I need to dynamically pull the RSS feed of a certain wordpress.com blog. The only information I need to pull is the excerpt content of the newest post (1 post total). When the wordpress.com blog is updated, the content on the index.php file should update to an excerpt of that newest blog post on wordpress.com.
I know how to do this with wordpress.org self-hosted blog (logging in to the wp-login.php file and adding the loop to the external index.php file), but unfortunately it doesn't work the same with wordpress.com blogs since they are automatically hosted.
Magpie RSS is your friend. I use it a lot to grab the most recent entry via RSS an show it on another webpage. I've only used it with self-hosted Wordpress blogs, but since it's based on the RSS feed I see no reason why it wouldn't work from wordpress.com as well.
An example from their website:
require_once 'rss_fetch.inc';
$url = 'http://magpie.sf.net/samples/imc.1-0.rdf';
$rss = fetch_rss($url);
echo "Site: ", $rss->channel['title'], "<br>";
foreach ($rss->items as $item ) {
$title = $item[title];
$url = $item[link];
echo "<a href=$url>$title</a></li><br>";
}
精彩评论