Import Feed With WordPress
This tutorial is for WordPress users. Sometimes, you want to import and attach an RSS Feed into somewhere in your page instead on sidebars. To do this, there are two possible method. Use simple PHP or JavaScript. In this post, i will talk about using the PHP one because it is simpler.
By default, you should use PHP commands fopen() or file_get_contents() to fetch the feed content and output the data, but in WordPress, there is already function about it, it called fetch_feed() . Thanks to WordPress again
Short of words, let have your PHP file ready to be editted. You can manually edit it on offline or using Theme Editor in Admin Page. And below is the short PHP code you should basically know:
<?php
$rss_url = Array("http://mr.hokya.com/","site2");
$feed = fetch_feed($rss_url);
wp_widget_rss_output($feed,"show_date=0&show_author=0&show_summary&items=5");
?>
Some benefit using this WordPress Declared Function
- It will fetches and shows your desired RSS Feed into somewhere you place that PHP code.
- It can fetches multiple RSS Feed from multiple URL and sorts it by the date
- This method uses fetch_feed() to automatically finds Feed URL of a site and fetches it into Feed Class.
- It uses wp_widget_rss_output to output the RSS Feed items. Naturally, it is used in RSS Widget
- You can determine whether show the date or not by changing the value of show_date into 1 for showing, or 0 for not showing.
- You can determine whether show the author or not by changing the value of show_author into 1 for showing, or 0 for not showing.
- You can determine whether show the summary or not by changing the value of show_summary into 1 for showing, or 0 for not showing. If you choose 0, you will only see the title of the item.
- You can specify the max items of RSS feed to show within one site by changing the value items.






Brittany
Nice post mate
julian
thanks dude
gotsocialmedia.com
I liked it too !!!
Natividad Deacetis
Don’t wait any longer to boost your business and skyrocket your profits by doing business with one of the fastest growing economies on the planet — CHINA!
josh
i am not sure where to put the short php code … which php file? my goal is to have multiple blog feeds, with latest excerpts, showing up on one of my wordpress pages.
thanks!
josh
julian
you can put the code on any PHP files of your Theme
if you want it to be shown over the frontpage, then put it on your index.php or home.php(if exists) on your theme’s PHP
and for information:
information gathered from database, such as posts, pages, and widgets, can not render the PHP
so the way to implement this is by editting the HTML/PHP code