How to add other’s website feed into our site?. For theme that widget ready, we can use built-in widget that could help us to add other’s site feed, but if our theme is not widget ready?
To add other’s site feed using php script, you can use script like this :
- <h2><?php _e('Recent news from Some-Other Blog:'); ?></h2>
- <?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://example.com/rss/feed/goes/here');
- 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>
- <?php if ($maxitems == 0) echo '<li>No items.</li>';
- 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'); ?>'>
- <?php echo $item->get_title(); ?></a>
- </li>
- <?php endforeach; ?>
- </ul>
Change this url with your desired feed url :
http://example.com/rss/feed/goes/here
I copy pasted this script from wordpress codex site. You can search anything there, but maybe it will takes time. So, i post it here, to help us all. Use that script to add other’s site feed into your own site.




Facebook comments: