Sebenarnya WordPress sudah menyediakan fitur ini lewat widget yang bisa kita letakkan di sidebar. Tapi bagaimana jika kita ingin meletakkan RSS di bagian lain selain sidebar, di footer misalnya. Untuk keperluan tersebut wordpress sudah menyediakan script-nya.
< ?php // Get RSS Feed(s)
include_once(ABSPATH . WPINC . '/feed.php');
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed('http://www.kompasiana.com/feed');
if (!is_wp_error( $rss ) ) : // Checks that the object is created correctly
// Figure out how many total items there are, but limit it to 5.
$maxitems = $rss->get_item_quantity(5);
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items(0, $maxitems);
endif; ?>
<ul class="f-list">
< ?php if ($maxitems == 0) echo '<li>No items.';
else
// Loop through each feed item and display each item as a hyperlink.
foreach ( $rss_items as $item ) : ?>
<li>
<a href='<?php echo $item->get_permalink(); ?>' title='< ?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>' target='_blank'>
< ?php echo $item->get_title(); ?></a>
</li>
< ?php endforeach; ?>
</ul>Script di atas bisa kita tambahkan di bagian mana saja dari theme yang kita inginkan. Ganti “Recent news from Some-Other Blog” dengan judul feed yang ingin ditampilkan. Dan ganti “http://example.com/rss/feed/goes/here” dengan URL feed yang diinginkan. Seperti di widget, kita juga bisa menambahkan lebih dari satu feed di satu halaman.
Semoga bermanfaat

One Response
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.