如何从wordpress.com上获取RSS提要并将该提要的最新帖子添加到另一个网站? [英] How do I take an RSS feed from wordpress.com and add the newest post of the feed to another website?

查看:97
本文介绍了如何从wordpress.com上获取RSS提要并将该提要的最新帖子添加到另一个网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用php文件构建一个静态站点.在index.php文件上,我需要动态提取某个wordpress.com博客的RSS提要.我需要提取的唯一信息是最新帖子的摘录内容(共1个帖子).更新wordpress.com博客后,index.php文件上的内容应更新为wordpress.com上最新博客文章的摘录.

I 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.

我知道如何使用wordpress.org自托管博客(登录到wp-login.php文件并将循环添加到外部index.php文件中),但是不幸的是,它无法正常工作使用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.

推荐答案

喜p RSS 是您的朋友.我经常使用它来通过RSS获取最新条目,并在另一个网页上显示它.我只在自托管的Wordpress博客中使用过它,但是由于它基于RSS feed,因此我没有理由也无法在wordpress.com上使用它.

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.

他们网站上的示例:

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>";
}

这篇关于如何从wordpress.com上获取RSS提要并将该提要的最新帖子添加到另一个网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆