开发者

RSS feed into a sigle wordpress page

I am trying to implement a RSS feed into a single page on wordpress. I do not want to insert it into the page.php template. However, when I insert my code into the html portion of wordpress the code is the only thing that shows up.

开发者_如何学编程The code I am using is:

<?php if(function_exists('fetch_feed')) {

    include_once(ABSPATH . WPINC . '/feed.php');                    // include the required file
    $feed = fetch_feed('http://feeds.feedburner.com/jquery/');  // specify the source feed

    $limit = $feed->get_item_quantity(7); // specify number of items
    $items = $feed->get_items(0, $limit); // create an array of items

}
if ($limit == 0) echo '<div>The feed is either empty or unavailable.</div>';
else foreach ($items as $item) : ?>

<div>
    <a href="<?php echo $item->get_permalink(); ?>" 
      title="<?php echo $item->get_date('j F Y @ g:i a'); ?>">
        <?php echo $item->get_title(); ?>
    </a>
</div>
<div>
    <?php echo substr($item->get_description(), 0, 200); ?> 
    <span>[...]</span>
</div>

<?php endforeach; ?>

Is there a way to insert a RSS feed into a single page without doing some extreme coding?


To execute PHP in the WP editor, you need to a enable that capability with a plugin, such as http://wordpress.org/extend/plugins/exec-php/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜