在我的wordpress网站上显示第三方Feed

时间:2012-06-07 10:30:36

标签: wordpress rss

我有这个wordpress网站& classesoy的Feed显示为http://site.com/category/category_name/feed。这显示了“category_name”类别中的所有帖子。我想要的是显示从我的其他网站托管的自定义Feed。不是默认的wordpress rss feed。

这可能吗?

2 个答案:

答案 0 :(得分:1)

试试这个

$xml = '//site.com/category/category_name/feed';
            $doc = new DOMDocument();
            $doc->load($xml);
            $item = $doc->getElementsByTagName('item');

            //$data = array();

            for($i=0; $i<=3; $i++){
                $title = $item->item($i)->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue;
                $link = $item->item($i)->getElementsByTagName('link')->item(0)->childNodes->item(0)->nodeValue;
                echo '<a href="' . $link . '" target="_blank"><h2>' . $title . '</h2></a>';
            }

并通过此代码显示源代码的PHP代码..

了解更多信息,请访问 access cross domain feeds with php 希望这对您有帮助。

答案 1 :(得分:0)

有许多不同的方法可以显示来自WP网站中其他网站的Feed,只需将Feed或完整的Feed内容显示为帖子。

请参阅FeedWordPress | simple and flexible Atom/RSS syndication for WordPressWordPress › SimplePie Plugin for WordPress « WordPress Plugins以及Developer's Guide - Google AJAX Feed API - Google CodeMagpie RSS - PHP RSS Parser