![]() |
|
|||||||
| Blog(博客)/Wiki(维客)/RSS/Cms Blog(博客)/、Wiki(维客)、RSS、Cms等WEB 2.0相关技术讨论专区。 |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
IP: 117.95.50.177
|
|||
|
|||
|
利用第三方RSS and Atom Feed Framework调用WordPress
我使用的是这种方法,好处是调用代码是静态的,而非HTML代码。步骤如下,下载SimplePie Plugin for WordPress或者下载SimplePie最新版,将“simplepie.inc”上传到主机相应的目录,然后在需要调用的地方粘贴下面的代码即可(以万戈的Rss地址为例)。 <?php require_once('simplepie.inc'); $feed = new SimplePie(); $feed->set_feed_url('http://www.glassesdaily.com/feed'); $feed->init(); echo '<ul>'; $i = 1;foreach($feed->get_items() as $item){ if($i<15){ echo '<li><a href="'.$item->get_permalink().'">'.$item->get_title().'</a><br />'. "\n"; echo substr($item->get_description(),0,180).'...</li>'."\n"; $i++; }} echo '</ul>'; ?> 当然,可以根据自己的需要修改这个代码的。 |
![]() |
| Currently Active Users Viewing This Thread: 3 (0 members and 3 guests) | |
|
|