Iko has an idea of showing Live RSS feeds in Wordpress Pages. Here is my solution to accomplish this task.
Wordpress supports Page templates, on which this solution is based.
- Locate page.php in your template's direcotory.
- Copy the file and rename it to something like rsspage.php, and then open it for editing
- Add or modify header comment of the file to:
<?php /* Template Name: RSS Page */ ?>
- Locate the_content() function in the code and insert the following code after it:
<?php $values = get_post_custom_values('RSS'); $items = array(); if (!empty($values)){ $url = $values[0]; include_once(ABSPATH . WPINC . '/rss.php'); $rss = fetch_rss($url); $maxitems = 10; $items = array_slice($rss->items, 0, $maxitems); } ?> <?php if (empty($items)) _e("No items"); else foreach ($items as $item ) : ?> <a href="<?php echo $item['link']; ?>"> <?php echo htmlspecialchars($item['title']); ?> </a> <?php endforeach; ?>
- Save rsspage.php into your template directory
- Create new page in Wordpress: Write->Page and change Page Template to RSS Page from the right column.
- Save the page
- Go to Manage -> Pages and Edit the page You just created.
- Scroll to the bottom and add new field in Custom Fields named RSS with the RSS feed, You want to show as value. Click Add Custom Field and then Publish the page
That's all.
The Main code section is provided by Iko
Note! The Create -> Edit procedure is required due to bug in Wordpress 2.3.1