How to Import and Display RSS Feeds in WordPress • Perishable Press Page 1 of 25

Perishable Press Import and Display RSS Feeds in WordPress

Published Sunday, April 26, 2009 @ 2:35 pm • 53 Responses

Importing and displaying external RSS feeds on your site is a great way to share your online activity with your visitors. If you are active on Flickr, Delicious, , or Tumblr, your visitors will enjoy staying current with your updates. Many sites provide exclusive feeds for user-generated content that may be imported and displayed on virtually any web page. In this article, you will learn three ways to import and display feed content on your WordPress- powered website — without installing yet another plugin.

On the menu for this tutorial:

• Importing and displaying feeds with WordPress & Magpie (simple method) • Importing and displaying feeds with WordPress & Magpie (advanced method) • Importing and displaying feeds with SimplePie (WordPress not required)

Sound good? Let’s get to it..

Importing and displaying feeds with WordPress & Magpie (simple method)

If you only need to display the titles of a feed, you can take advantage of the built-in WordPress function, wp_rss(), which provides WordPress with essential feed-fetching and feed-parsing functionality. All you need to do is place the following code into the desired display location within your theme template file (e.g., sidebar.php):

In the first line, we include the required wp_rss() function from the .php file (rss- functions.php in older versions of WordPress). In the second line, we specify two parameters: the first is our feed URL and the second is the number of titles to display. Simply edit these two parameters and enjoy the results.

Importing and displaying feeds with WordPress & Magpie (advanced method)

Magpie provides an XML-based RSS built with PHP. WordPress uses Magpie to parse RSS and feeds and display them on your website. Magpie parses feeds for two different WordPress functions:

• wp_rss() - fetches and parses feeds for instant/automatic output • fetch_rss() - fetches and parses feeds for advanced/customized output

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 2 of 25

Each of these functions uses the Snoopy HTTP client for feed retreival, Magpie for feed parsing, and RSSCache for automatic feed caching.

The wp_rss() function fetches and parses feed content and then outputs an unordered list containing each of the feed’s post titles (see previous section). The fetch_rss() also fetches and parses feed content and will output the results according to your specific script configuration. Instead of just spitting out titles, the fetch_rss() function enables us to display any available feed data in customized format. Let’s look at an example.

items, 0, 7); // specify first and last item ?>

Once placed in the desired location in your WordPress theme template file, the previous code will output the title and description (content) of the seven most recent feed items. Simply edit the three variables in the first three lines of the script and you are good to go. Then, once you see that everything is working as intended, feel free to modify the markup as you see fit. Before moving on, let’s walk through the method in sequential fashion:

• Include the script - specify the path to rss.php (or rss-functions.php in older versions of WordPress) • Specify your feed URL - specify the URL of the feed you would like to display • Limit number of items - edit the two numbers to reflect the numbers of the first and last feed items, respectively • Empty check - before running the loop, check that the feed isn’t empty • Begin the loop - begin the standard foreach loop • Display the items - for each feed item, display the post title, title link, and post content • Wrap it up - close the loop and end the empty check

Notes on using WordPress/Magpie If you are calling feeds that may or may not include a description, you may want to avoid the output of empty paragraph elements (

) by wrapping the description with a conditional check like so:

Also, if the feed isn’t showing, try replacing the associated line with this:

$feed = @fetch_rss('http://domain.tld/your-feed/');

For an alternate way of checking for the presence of a working feed, replace the empty check with this:

items) && 0 != count($rss->items)) : ?>

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 3 of 25

You can also clean up feed output by taking adavantage of WordPress’ built-in filtering functionality:

Here are some of the variables that are available from your feeds (not sure if all of these work):

• $item['link'] - post • $item['title'] - title of the post • $item['pubdate'] - post publication date • $item['description'] - post excerpt or content • $item['creator'] - post author (does this work?) • $item['content'] - post content (does this work?)

Note that when using the $item['pubdate'] variable, the default output will look like this:

Mon, 11 Jul 2050 01:11:11 +0000

Fortunately we can clean this up a little bit by parsing it with PHP’s substr() function like so:

$pubdate = substr($item['pubdate'], 0, 16);

Which will output the following date format:

Mon, 11 Jul 2050

And, finally, an alternate loop format that defines the number of items to display without using the array_slice() function:

items[$i]; ?>

Importing and displaying feeds with SimplePie (WordPress not required)

For more robust feed fetching in the most simple way possible, SimplePie is the perfect choice. SimplePie is a blazing fast PHP class that is easy to learn and simple to use. With a few quick steps, you can use SimplePie to retrieve and parse any RSS or Atom feeds and display them on any PHP-enabled website (WordPress is not required). SimplePie works great with its default settings, but it is also highly customizable. You can use SimplePie to display any type of data from any number of feeds, and it even works without WordPress. Sound good? Here’s how to setup SimplePie in three easy steps:

• Download SimplePie and unzip • Place the “simplepie.inc” into a folder named “php” located in the web-accessible root directory of your website • Create a folder named “cache” (also in the web-accessible root directory) and make sure that it’s writable by the server (i.e., CHMOD to 755, 775, or 777)

That’s all there is to it. Once SimplePie is properly setup on your server, you may check that it’s working by uploading the following code to the web page of your choice (edit as specified):

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 4 of 25

get_title(); ?>

get_description(); ?>

If the feed title and description don’t appear on the page, check the path to simplepie.inc in the first line and also verify that the feed URL is correct and that the feed is working properly.

Once everything is working and flowing like butter, the possibilities are endless. To get you started, let’s expand the previous “testing” code to include the title, link, content and date for the seven most recent feed items:

$feed = new SimplePie(); // bake a new pie $feed->set_feed_url('http://domain.tld/your-feed/'); // specify feed url $feed->set_cache_duration (999); // specify cache duration in seconds $feed->handle_content_type(); // text/html utf-8 character encoding $check = $feed->init(); // script initialization check ?>

get_title(); ?>

get_description(); ?>

get_items(0, 7) as $item) : ?>

get_title(); ?>

get_description(); ?>

Posted on get_date('j F Y @ g:i a'); ?>

Feeds currently not available

Please try again later

That is the code I start with when implementing SimplePie on client projects. It serves as an easy- to-customize template that incorporates plenty of functionality and outputs feed content in common format. Let’s walk sequentially through the code for better understanding of functionality and proper use.

Setting the variables

1. Path to the SimplePie script - edit according to your specific setup 2. new SimplePie - setup a new instance of SimplePie feed variable 3. Feed URL - specify the URL of the feed you would like to display 4. Cache duration - specify how long the feed should be cached (seconds) 5. Character encoding - ensures that content is in text/html, UTF-8 format 6. Script check - sets a variable upon successful script initialization

Format the output

1. Feed title and link - wrapped in

tags and placed before the loop because only one title exists for each feed 2. Feed description - wrapped up in paragraph tags and placed before the loop because only one description exists for each feed 3. Initialization check - if the $check variable is set, then continue processing the script

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 5 of 25

4. Begin the loop - standard foreach loop with parameterized argument for setting the number of feed items to display 5. Feed items - for each feed item, display the post title, title link, post content, and post date. 6. End the loop - terminate the recursive processing of feed items 7. Else condition - if the $check variable is not set, then display the following code 8. Else message - text/markup to display if the initialization check fails and the feed is not displayed 9. End the if condition - conclude the script by terminating the if condition

Notes on SimplePie It is possible to merge feeds into a single stream by replacing the associated lines with the following:

set_feed_url(array( 'http://domain.tld/your-feed-01/', 'http://domain.tld/your-feed-02/', 'http://domain.tld/your-feed-03/' )); ?>

Also, you can truncate the number of words that appear in the content of each feed item by using PHP’s substr() function:

get_description(), 0, 180); ?>

In the foreach() loop, you may specify the number of the first and last feed to process by editing the “0” and “7” in the following line:

get_items(0, 7) as $item) : ?>

For WordPress users who would rather not mess with all of the “under-the-hood” code stuff, there is an awesome SimplePie plugin that automates just about everything. It should be noted, however, that the SimplePie plugin consists of two different plugins and requires a significant amount of time and effort in order to implement. It’s a great set of plugins, but I would argue that the manual implementation method is easier.

Finally, keep in mind that your feeds are cached according to either the default setting or your specified cache duration. The default caching duration is one hour, which is suitable for most implementations. Don’t forget that, for caching to work, SimplePie must have write access to the cache directory (see above).

With SimplePie, the options are endless. This tutorial is enough to get you started, but you should check the SimplePie Wiki for more comprehensive documentation.

Feed ‘em!

With these versatile, easy-to-use techniques for importing and displaying external feeds, virtually anything is possible. If you are using WordPress, you can take advantage of the built-in Magpie functionality and display feeds quickly and easily. For non-WordPress users or for those seeking more control over the feed importation and display process, you will find all of the flexibility you need with SimplePie. These methods will help you provide more content to your readers and do so without getting locked into using yet another needless plugin. So go forth and feed that insatiable audience of yours! :)

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 6 of 25

Copyright2009PerishablePress

About this article

This is article #686, posted by Jeff Starr on Sunday, April 26, 2009 @ 2:35pm. Categorized as WordPress & tagged with feed, loops, php, rss, tips, tricks, tutorials, WordPress. Updated on May 19, 2009. Visited 71575 times. 53 Responses »

• Subscribe • Bookmark •

Related articles

• Consolidate and Localize Your WordPress Feeds • Miscellaneous Code Snippets for WordPress, Windows, and Firefox • Horizontally Sequenced Display Order for WordPress Posts in Two Columns • 3 Ways to Exclude Content from WordPress Feeds • Redirect WordPress Individual Category Feeds to Feedburner via HTAccess • Display Random Posts from Specific Tags or Categories • Redirect WordPress Feeds to Feedburner via htaccess (Redux)

Dialogue

53 Responses Jump to comment form

1 • Peter Westwood

April 27, 2009 at 12:06 am

SimplePie is in trunk for WordPress 2.8

It would be good to update this to include what will be available then!

2 • Jeff Starr

April 27, 2009 at 7:09 am

Yes, I thought about waiting until 2.8, but figured I could just update the article when it is released. I am looking forward to SimplePie and WordPress working together — hopefully it will mean even more flexibility for designers and developers. Cheers!

3 • Frank

April 28, 2009 at 2:33 am

Nice post! I think it is better for the date you use the function of WordPress for formating the date with the options of the : $pubdate = date_i18n(get_option('date_format'), $pubdate); Best regards Frank

4 • Jeff Starr

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 7 of 25

April 28, 2009 at 9:20 am

Excellent tip, Frank — thanks! :) The workaround mentioned in the post was a bit insufficient. This looks like it will work much better. Thanks for sharing!

5 • Frank

April 28, 2009 at 11:21 pm

@Jeff: thanks for your answer; a small modification for my tipp: $pubDate = date_i18n( get_option('date_format'), strtotime( $item ['pubdate'] ) ); This works fine and the return is a date in the format of the blog-options.

6 • Jeff Starr

April 29, 2009 at 9:21 am

@Frank: Perfect! Thank you for the follow-up :)

7 • teddY

May 1, 2009 at 11:15 pm

Wow, a really handy tutorial, Jeff! If it weren’t you writing this tutorial, I wouldn’t have found a way how to parse my Digg feed so that I can display it on my blog. I know that Wordpress has a function to import a RSS feed, but I have no idea how to process the information contained in it. Your guide saved me from all the need of Googling and piecing together snippets of code from all kinds of webpages, especially for the parsing of the time (pubdate). I have no clue how to change the way it is displayed until you wrote about it.

I’m considering to install a WP plugin called Lifestream to better manage all my social website activities (mainly Twitter, Digg and Flickr), and it seems to be a nice nifty plugin to try out. Of course, if it all fails, I can always use your failsafe method :)

8 • Thomas Scholz

May 4, 2009 at 10:12 am

Passing an URL to the SimplePie constructor triggers the automatic modus. Any later configuration attempts will fail. See: http://simplepie.org/wiki/reference/simplepie/start for details.

9 • Jeff Starr

May 4, 2009 at 11:50 am

@teddY: Always good to hear from you! Yes there are tons of great ways to use the feed- importing methods described in this article. There are many configurational options and different ways to use this type of functionality — not just with social media feeds, but with any other type of feed imaginable. I have several to which I regularly publish content, and so having an easy way to import the various feeds makes it easy to display all of my content in one place.

The Lifestream plugin for WordPress looks pretty cool. I recently discovered Sweetcron, which is a robust and standalone (& self-hosted) lifestream application. It’s pretty cool — I setup a test site and have been playing around with it, but there is tons of configurational options and stuff you can

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 8 of 25

do with it. I have seen some pretty sweet implementations around the Web. Maybe something to check out! :)

10 • Jeff Starr

May 4, 2009 at 12:12 pm

@Thomas Scholz: The article has been updated with the correct information. Thanks!

11 • davis

May 11, 2009 at 1:44 pm

Jeff,

Thanks for this! Works perfectly and easily! I have, hopefully, a quick question for you though.

Using Wordpress/Magpie advance as listed above:

What about if i want to pass a variable for the URL….

Maybe an RSS feed URL listed in the User.

I have this to echo the user name(s) field value(s) (using a plugin to create a custom field in which i place the url) :

$values = get_cimyFieldValue(false, 'TWITTERFEEDURL');

foreach ($values as $value) { $user_id = $value['user_id']; echo $value['user_login']; echo cimy_uef_sanitize_content($value['VALUE']); }

But if instead I wanted to pass the text value of that field into $feed = fetch_rss('http://domain.tld/your-feed/');

How would I do that? My attempts have proven my knowledge lacking ;)

12 • Jeff Starr

May 12, 2009 at 3:59 pm

@davis: Ugh! I wish I could help but unfortunately that exceeds my limits of knowledge on the topic as well. Very soon, WordPress 2.8 will be released and will be using SimplePie instead of Magpie. Perhaps this will provide enable you to get the help you need via the actively moderated SimplePie help forum..?

13 • davis

May 12, 2009 at 4:22 pm

ah, no worries Jeff.

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 9 of 25

I actually made it work making a variable equal to the function pulling the user field data (in this case being created by a plugin, but would work similarly for the “website” text field) - then i placed that variable into fetch_rss including all of that in a foreach after the data was retrieved and rss script included.

in my case (and in the event it helps someone else) the code is this:

include(ABSPATH.WPINC.'/rss.php'); // path to include script $values = get_cimyFieldValue(false, 'FEEDURL'); foreach ($values as $value) { $user_id = $value['user_id']; $FV = cimy_uef_sanitize_content($value['VALUE']); $feed = fetch_rss($FV); // specify feed url $items = array_slice($feed->items, 0, 3); // specify first and last item echo "".$value['user_login']."";

foreach ($items as $item) { echo "". $item['title'].""; } echo ""; }

now im off to try and filter the user role for which all of that is processed - wish me luck! haha.

thanks again Jeff!

14 • Jeff Starr

May 12, 2009 at 4:53 pm

Good luck — and thanks for the followup with code solution. Very cool. I tried formatting it with some indentation and whatnot, so let me know if anything is incorrect.

Now I know who to contact if I ever need some feed-parsing ninja skillz! ;)

15 • Zeeshawn

May 13, 2009 at 4:04 am

Awesome article Jeff, Clear , to the point and so easy to follow. I’ll be disposing of my plugins and coding up my own code from now on. Love it mate.

16 • mccormicky

May 13, 2009 at 4:29 am

Sweet! Now if only I had had all this info last fall. I would have suffered a lot less…

17 • Jeff Starr

May 13, 2009 at 4:09 pm

@Zeeshawn: Awesome, great to hear it — thanks for the feedback! :)

@mccormicky: I know what you mean. I should have written this article a year ago. I think it took me that long to understand it all myself. Oh well, at least it’s here for next time! :)

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 10 of 25

18 • Serge

May 19, 2009 at 8:17 am

Hi every one, you’ve done a great piece of code here. I was fighting to get one of my own categories listed as RSS in separate page … in vane before i’ve come here. I’ m barmen, not a code ninja… Just a note about WP 2.7:

1 i couldnt include my own feed using your code (got a warning for the second display about function array …)

2 have given the feed to google feedburner and set the feed url of the last one

result: Worked as a swiss watches and fixed as well the problem of the “Frenchy letters” é l’e etc…

Thanx a lot for your being born. the result is upgrading here : http://www.monmillion.fr/boutique/

19 • Mark

May 25, 2009 at 10:16 am

Man, I would love to get what @davis (comment #13) did working on my site but I am so far failing miserably. Help? Thanks!

20 • Jeff Starr

May 27, 2009 at 7:35 am

@Serge: I’m speechless! Thanks for the feedback :)

@Mark: I wish I could help here, but I am not familiar with the details of the technique. Hopefully davis will drop in again and lend a hand..

21 • davis

May 27, 2009 at 9:17 am

@mark

one thing to keep in mind before i break this down: the get_cimyFieldValue is a function created by the plugin Cimy User Extra Fields ( http://www.marcocimmino.net/cimy-wordpress- plugins/cimy-user-extra-fields/documentation/ ) I used it to create a field in the User profile. In this case a text field that i placed an RSS feed url into.

knowing that, here is the walk through.

include(ABSPATH.WPINC.'/rss.php'); — This is including the RSS magic

$values = get_cimyFieldValue(false, 'FEEDURL'); — This is saying the variable $values is equal to the function created by Cimy User Extra Fields false and ‘FEEDURL’ are options for that… in this case ‘FEEDURL’ is merely what i named the new text field i created with the plugin.

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 11 of 25

So it’s essentially just saying that I want $values to be the values of the new fields in the user profile, and Im calling to the new field ‘FEEDURL’ specifically - again that could be named anything.

foreach ($values as $value) {

Here it is saying run this for everyone of them

$FV = cimy_uef_sanitize_content($value['VALUE']); This line i’ve created the variable $FV to be equal to another function created by the plugin (one to echo the text of the field i created) and called upon in the $values line above.

$feed = fetch_rss($FV); // specify feed url —- Here im just telling it that $feed is equal to fetch_rss function with a feed value of the variable $FV which i created to call the function cimy_uef_sanitize_content which understands we are looking at the text field value for ‘FEEDURL’ per the $values = get_cimyFieldValues() line above.

$items = array_slice($feed->items, 0, 3); // specify first and last item – This is styling the $feed

The rest is echoing to the page. echo "".$value['user_login'].""; – This echos the user login name and below it is saying for each $item (that are pulled from $feed, that is fetching from $FV that is equal to cimy_uef_santize_content() that is limited from $values to ‘FEEDURL’) echo each feed entry as follows.

foreach ($items as $item) { echo "". $item['title'].""; } echo "";

I hope that helps to explain what i did. I still have to figure out how to only apply this whole thing to only one class of users (or to specific users) but i haven’t jumped back into yet to tackle that one.

22 • Patternhead

June 5, 2009 at 7:09 am

Great article Jeff.

I’m using WP 2.71. Does anyone happen to know if Magpie writes the cache to a table or to a file (I read somewhere that it adds entries to wp_options).

23 • Jeff Starr

June 7, 2009 at 6:09 pm

@Patternhead: I think you are correct — there is no file that I know of that is used by Magpie and no information about setting permissions etc for such a file. If I remember correctly, there is a “magpie” field in the options table, as you suggest. If anyone has any specific information on this please share. Thx.

24 • westi

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 12 of 25

June 7, 2009 at 10:11 pm

Yes WordPress does store the cache of the feed in the options table using a number of options (named magpie_x I think).

WordPress 2.8 feed functions, which now use SimplePie, will also cache in the options table but using the new transients functionality. What this does is store the information in the db unless you have installed an object cache plugin to use some thing like memcache for the WordPress object cache -then the transients are just stored in the cache.

25 • Patternhead

June 8, 2009 at 12:30 am

@Jeff @westi Thanks for the info. That’s interesting. So in terms of performance, I wonder which is quicker. Reading the cache from the DB or the disk.

I prefer to keep the DB as clean as poss so I’ve gone for simplepie (not the plugin) but this is a pretty big file 340kb so maybe it would be more efficient to just let WP use the DB for caching.

I’m planning to use 2.8 when we get RC1 so may have to take another look at this issue then. I haven’t use memcache before. Sounds like an idea for a future post Jeff ;)

26 • Jeff Starr

June 8, 2009 at 12:47 pm

@westi: Thanks for posting! :)

@Patternhead: Yes, that is a great idea for a post! Looking forward to 2.8 :)

27 • Brian

June 13, 2009 at 8:49 am

Hi, Thanks for this code. I had it working correctly at one point but made the mistake of including small images in WordPress codes which prevented the RSS feed from working correctly. However when I removed these I found that new items did not appear in the WordPress page although they do in the WordPress feeds. Using phpMyAdmin I have looked at the database expecting to find a file (either the last one displayed on the page or the one after) with some peculiar setting but no. I’ve deleted and re-entered all the affected bits but to no avail. The problem is displayed on

http://www.middlesbroughlourdes.co.uk/latest-news

where the sidebar links show the correct items but the body doesn’t.

Any ideas?

28 • Brian

June 13, 2009 at 10:42 am

Hi, Without doing anything on my part the problem described in my last post has disappeared. Curious. Once again, thanks for the code.

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 13 of 25

P.S. Just for the record I was using WP 2.8 on Safari 4 (Mac) and could see the exact same problem in iCab 4.6.0 and Camino 1.6.7.

29 • Jeff Starr

June 15, 2009 at 6:14 pm

@Brian: Glad to hear you got it working — thanks for posting the follow-up comment stating that the issue has been resolved. Much appreciated :)

30 • Lekha

July 21, 2009 at 9:12 pm

This is by far the best bit of information I have laid my eyes on!!!!!!!

kudos to you!!!

31 • Ray

July 22, 2009 at 2:55 am

Hey Jeff,

Great post as always! Also great comments by the visitors.

Didn’t know that WP stores RSS cache in the DB. That doesn’t sound very nice. I think I’m going to go with the manual SimplePie method.

Just adding my two cents, but probably the lightest RSS parser library is lastRSS. It’s also quite extendable, although not as full-featured as SimplePie.

By the way, you might want to update your tutorial for WP 2.8+ now ;)

32 • Josh

July 23, 2009 at 1:11 pm

What if you wanted to include a custom field that is the url to the rss feed? I’m having difficulties since it’s php within php. Do I have to store as a variable first?

33 • Josh

July 24, 2009 at 1:06 pm

I figured it out! You need to include global $post.

ID, 'rss', true); wp_rss($rssfeed, 5); ?>

34 • Josh

July 24, 2009 at 1:07 pm

Oops looks like it stripped the code. Let me try that again.

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 14 of 25

: { k w -

35 • Jeff Starr

July 25, 2009 at 4:43 pm

Thanks for the follow-up post, Josh — glad to hear you got it working :)

(sorry for the code hassle — WordPress likes to gobble PHP!)

36 • Tim

July 25, 2009 at 7:49 pm

How can we use the simple pie method described above now with WP 2.8?

37 • Jeff Starr

July 26, 2009 at 8:22 am

Hi Tim, as of WordPress 2.8, we can include and display feeds according to the SimplePie documentation. The only difference is that we use this:

To return the feed as a standard SimplePie object. Everything else is according to the SimplePie documentation.

38 • Corey O

August 2, 2009 at 6:53 am

Is there any way to include an image while displaying the feed titles and description?

39 • Jeff Starr

August 2, 2009 at 3:29 pm

Hi Corey, I think this may help:

http://perishablepress.com/press/2007/02/04/feed-your-image-via-atom-or-rss/

40 • Corey O

August 4, 2009 at 7:17 am

Thanks Jeff,

Nice site by the way. The background image is pretty awesome.

41 • John

August 17, 2009 at 1:00 pm

Good bits, will pass them along!

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 15 of 25

Very useful site overall, thanks for sharing.

42 • WebDev.im

August 30, 2009 at 8:49 pm

Very nice site. I will be trying to integrate your feed code into my site pronto. Thanks for the resource.

43 • National Reporter

September 3, 2009 at 3:46 am

I was searching for a tool that would help me to feed articles for me to my website and i found it here and i think its very useful stuff , i need more closely look to include it in my wordpress, thanks for sharing and am going to use it in my blog right away.. Thank You.

Trackbacks /

1. Lenguajes X » Importar RSS en WordPress sin usar un plugin 2. Importar RSS en WordPress sin usar un plugin | Blog Ascariz 3. Enlaces de la semana (III) | Mareos de un geek 4. links for 2009-05-27 « Rob Parker – robparker.org.uk 5. » Importar RSS en WordPress 6. WordPress/WordPress MU: RSS On A WordPress Page | Richard Bui | Bui4Ever.com 7. Knowledge Base 8. Come (ma Soprattutto Perché) Implementare un Sideblog - seconda parte » Francesco Gavello - Blog Marketing Tips, Web & Blogosfera 9. online backup programs software technical comparison | yon Leveron blog 10. Twitter for How to Import and Display RSS Feeds in WordPress • Perishable Press [perishablepress.com] on Topsy.com

Subscribe to comments on this post

Share your thoughts..

Top • Read official comment policy

Name

Email

Website

Comment

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 16 of 25

m

n

Submit Comment

Subscribe to comments gfedcb Notify me of follow-up comments via [or] Subscribe to comments on this post via RSS

← Previous post • Next post →

« 4G Series: The Ultimate Referrer Blacklist, Featuring Over 8000 Banned Referrers • Best Practices for Error Monitoring »

• Subscribe • Contact • Search • About • Archives

Subscribe to Perishable Press

+ 2893.13 Subscribers

• Verfiy subscriber count • Learn more about feeds

• Subscribe to main content • Subscribe to all comments • Subscribe via email

Elsewhere..

• Subscribe to my Twitter feed • Subscribe to my Tumblr feed • Subscribe to my FriendFeed

Contact Perishable Press

• Contact Jeff via email • Contact Jeff via form

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 17 of 25

• Follow me on Twitter • Network with me at LinkedIn • Network with me at

Elsewhere..

• Perishable @ Delicious • Perishable @ Technorati • Perishable @ StumbleUpon

Search Perishable Press

Type and press enter to search the site..

About Perishable Press

Perishable Press is the virtual playground of Jeff Starr — visionary, founder and lead developer of Monzilla Media, a small web and graphic

Read more..

• More About Perishable Press • A Closer Look at Perishable Press • About Perishable Press, First Edition

Perishable Press Archives

Archives and Sitemaps..

• Perishable Press Archives • Perishable Comment Archive • Perishable Category Archive • Perishable Press Archive • Perishable Press XHTML SiteMap • Perishable Press XML SiteMap

Informational Pages..

• Link to Perishable Press • Frequently Asked Questions • Perishable Press ChangeLog • Accessibility Statement • Welcome to Dungeon!

• JavaScript • XHTML • CSS • PHP • SQL • Apache

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 18 of 25

Exclusive JavaScript Tutorials

• Compressed JavaScript Compression • Unobtrusive JavaScript Dynamic Clock • Toggle Element Visibility via JavaScript • Nine Ways to Embed Flash with JavaScript • Unobtrusive Auto-Clear and Restore Multiple Inputs • Open External Links as Blank Targets via Unobtrusive JavaScript

JavaScript Tag Archive

Exclusive (X)HTML Content

• (X)HTML Document Header Resource • Embed External Content via iframe and div • Bare-Bones HTML/XHTML Document Templates • Rethinking Structural Design with New Elements in HTML 5 • Wrapping Your Head around Downlevel Conditional Comments • Content Negotiation for XHTML Documents via PHP and htaccess

(X)HTML Tag Archive

CSS Tips, Tricks, and Hacks

• A Killer Collection of Global CSS Reset Styles • Absolute Horizontal and Vertical Centering via CSS • Lessons Learned Concerning the Clearfix CSS Hack • Pure CSS: Better Image Preloading without JavaScript • Maximum and Minimum Height and Width in Internet Explorer • Sharpen Your Site by Removing Unwanted Link Border Outlines

CSS Tag Archive

Exclusive PHP Articles

• How to Block IP Addresses with PHP • Advanced PHP Error Handling via PHP • Eliminate 404 Errors for PHP Functions • Drop-Dead Easy Random Images via PHP • 5 Easy Ways to Display Syntax Highlighted PHP Code • Content Negotiation for XHTML Documents via PHP and htaccess

PHP Tag Archive

Featured SQL Tutorials

• Fixing Mint after Switching Servers • MySQL Magic: Find and Replace Data • Backup that Database with phpMyAdmin • Enable or Disable Comments and Pingbacks via SQL • Reduce the Size of the WP-ShortStat Database Table • Remove Spam from the Comment Subscription Manager

SQL Tag Archive

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 19 of 25

Apache & HTAccess Voodoo

• Stupid htaccess Tricks • Custom HTTP Errors via htaccess • How to Block Proxy Servers via htaccess • Advanced PHP Error Handling via htaccess • Ultimate htaccess Blacklist 2 (Compressed Version) • Creating the Ultimate htaccess Anti-Hotlinking Strategy

HTAccess Tag Archive

• WordPress • Tutorials • Blogging • Series Archive

Popular WordPress Articles

• Perishable Press WordPress Plugins • Perishable Press WordPress Themes • 6 Ways to Customize WordPress Post Order • Perishable Press Triple Loop for WordPress • Comprehensive HTAccess Canonicalization for WordPress • How to Display Your Twitter Posts on Your WordPress Blog

WordPress Tag Archive

Exclusive Tutorials

• Hacking Firefox Extensions • How to Add Meta Noindex to Your Feeds • Launch Multiple Programs with One Click • Protect Your Site Against UserCash and Other Scumbags • BlackBerry Curve as Wireless Bluetooth Modem for OS-X Mac • Install Windows 98SE and Windows XP Pro on Sony Vaio PCG-F430

Tutorials Tag Archive

Blogging Ideas and Insights

• The Pros and Cons of Blogging • Five-Step Feed-Portfolio Makeover • Unicode Character Reference for Bloggers • 10 Firefox Extensions that I Use Every Day • Notes and Tips for Better • Bloggers Toolbox: Strategic Elements for a Perfect About Page

Blogging Tag Archive

Exclusive Series Articles

• Blacklist Candidate Series Summary • WordPress Basics — Series Summary • The Perishable Press Dofollow Series

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 20 of 25

• Series Summary: Building the 3G Blacklist • Perishable Press CSS Hackz Series Summary • Series Summary: Obsessive CSS Code Formatting • Series Summary: Minimalist Web Design Showcase Perishable on Twitter

Perishable’s Twitter Feed

Follow Perishable @ Twitter

“ Praise the Lord the kids are finally back in school. Six hours of pure silence :) ” Perishable on Tumblr

Perishable’s Tumblr Feed

Join Perishable @ Tumblr

help me in plain english

Mon, 31 Aug 2009

This has got to be the most ironic comment I have ever read:

“hi i dun a stupid noooby mistake and dint think about encrytion i just put a pass in the change pass box and now when i attempt to see my main.php or index.php its sayin password no and error how can i reset back to having no password or were can i edit the bit so that a pass is automattically seen or if not posable how can i make it so i can put in the pass i made at some point so i can login this way? the 3rd is most prefered as this will help me with other projects i am planning as i am a php noob :s plz sum1 hu is clever help me in plain english”

Thanks, “jay” — you made my week with that one.

Redirection After Registration

Tue, 04 Aug 2009

After searching high and low for an unobtrusive method of redirecting users to a custom URL after registering at a WordPress-powered site, I finally resorted to (gasp) hacking the core. I simply could not find a better way of doing it that didn’t require a ton of additional code. I found several ways of redirecting users to various URLs after logging in and out, but absolutely nothing seems to exist on redirecting users to, say, the home page, or better yet, back to the current page after registering as a subscriber (or whatever role the Admin has set for new registrations). Indeed, the only way to direct a user to some page other than the default WordPress “Registration complete. Please check your e-mail.” screen (which looks just like the WP Login page, btw) is to hack the wp-login.php file.

Thus, for the sake of remembering this technique, helping others, and/or “inspiring” someone to find a solution, here’s how to hack WordPress to change the page that users are directed to after they register (via submission of a username and email address). First, open the wp-login.php file and find the line that says, “wp_redirect('wp-login.php?checkemail=registered');”. That’s the key right there. To change the location, replace the part that says, “wp-login.php?

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 21 of 25

checkemail=registered” with the URL to which you would like to direct the newly registered users. You may use full URLs or even relative paths to a specific file. That’s all there is to it. It’s still hacking the core, but not by much ;)

Remember, if you’re going to hack the core, make a note of the change(s) and refer to it before/after each subsequent upgrade.

A 500KB wp_options Table is Too Much

Thu, 09 Jul 2009

After my server crashed, I found myself restoring my site’s WordPress database. While there, I decided to dig around a bit and make sure everything was up to snuff. While looking through the wp_options table, I was surprised to discover that WordPress seems to cache around 400KB of “Planet WordPress” dashboard feeds (among other things). That’s a little extreme if you ask me, so I decided to clean things up and reduce my overall database size by around half a megabyte. Here’s how I did it using my archaic 2.3 version of WordPress and phpMyAdmin.

Step One: Take Some Notes

Before doing anything, copy and paste a few text snippets from your dashboard feeds. This will enable you to easily locate the oversize options fields for removal in Step Three. Note: from the various feed entries make for good search candidates.

Step Two: Kill the Feed

Place this in your theme’s functions.php file (props to Michael Shadle for the code):

function remove_dashboard_feeds() { remove_action(‘admin_head’, ‘index_js’); } add_action(‘admin_head’, ‘remove_dashboard_feeds’, 1);

Step Three: Clean up Your wp_options Table

Once that is done, you may clean up your database by doing a quick search for some of the text snippets (permalinks work great) that you copied from the dashboard feeds in Step One. The field (s) that you find should be named something like “rss_123abc…”, where the “123abc…” is some long, apparently random alphanumeric string. Once you have disabled the feed via functions.php, feel free to reduce the size of your database by deleting the field(s) used to store data for the dashboard feed.

Doing this saved me an extra ~400KB of space, which is much-needed as the size of my Perishable Press database continues to grow.

Stop Errors when Running Multiple Themes

Sat, 30 May 2009

Another quick WordPress tip for anyone running multiple themes in WordPress. If your site provides users the option of selecting from a number of different themes, you may have noticed errors like this in your PHP error log:

[28-May-2009 05:46:50] PHP Warning: main(): Failed opening ‘/…/press/wp- content/themes/requiem/searchform.php’ for inclusion

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 22 of 25

(include_path=’/usr/lib/php:.:/usr/php4/lib/php:/usr/local/php4/lib/php’) in /…/press/wp- content/themes/default/sidebar.php on line 6

[28-May-2009 05:49:02] PHP Warning: main(/…/press/wp- content/themes/requiem/searchform.php): failed to open stream: No such file or directory in /…/press/wp-content/themes/default/sidebar.php on line 6

These errors happen when a user loads a page using a non-default theme that calls the searchform.php file via the following code:

Since the template path is based on the default theme, this code will attempt to locate searchform.php in the default theme’s directory. Thus, non-default themes that contain this code will produce the PHP errors shown above.

Fortunately, eliminating this problem is as easy as replacing the “TEMPLATEPATH” with the actual path to the file in your theme. Something like this:

..where the “…” (ellipses) represents something like, “home/public/domain” or similar, depending on your setup. This path must be the absolute path to work properly. Repeat this process as necessary for any other instances of “TEMPLATEPATH”.

That’s all there is to it — no more pesky PHP errors for missing template files! :)

Maximum Characters for Google Meta Tags

Wed, 27 May 2009

I was going to post this on Twitter, but the service was down or otherwise not responsive (as it frequently is), so I decided to post the information here at Tumblr instead.

After trying to determine the maximum number of characters allowed for meta title, keywords, and description tags, I realized that the answers are not always clear, even where Google is concerned. One SEO site says one thing, someone in the Google forums says another. Bloggers and designers all seem to have their own opinions.

Fortunately, many of the proclaimed answers I encountered all seem to converge on a common set of values for the three meta tags. Here are my findings:

meta title tag: Perhaps the most widely agreed upon max-character value of the bunch, 60 characters (including spaces) seems to be the common denominator for the all-important title tag. Of course, you can make your titles as long as you want, but keep in mind that Google will only display the first 60 characters.

meta description tag: Lots of disagreement on this one, with some “experts” claiming a 160- character maximum (including spaces) and others saying that the value is more like 150. The range of values for the description tag ranged from over 200 to around 150, with 160 being a very common value. Thus, to be on the safe side, I recommend meta description tags of no more than 150 characters.

meta keywords tag: How many keywords can you stuff into the meta keywords tag? Well, that all depends on how many characters each of them contains. Lots of disagreement on this one, with lots of folks pointing out the utter foolishness of even bothering with meta keywords. Oh well, I still use them, and have determined that 800 (including spaces) seems to be a safe number of maximum characters for the meta keywords tag.

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 23 of 25

Of course, I am only blogging this info for my own future use, but I like to think of myself as a reliable source of information, so perhaps these max-character values will be useful to you as well. If you would like to chime in on the topic, please do so via Twitter. Any previous comments may be seen by clicking here.

Read more on Tumblr.. Subscribe to Comments Recent Dialogue

• Ken: For some reason, I can't get this to work in Firefox 3.5.2. Any ideas?... • Abbott: Ha! Success. I guess the new version fixed it. Also, I added the readme.txt tweak. Thanks man. I suppose you could delete this exc... • Abbott: jeff, 1. latest 2.8.4 2. yes, full admin level 10 3. no. i did receive other server errors, because i've applied the 4G. since t... • National Reporter: I was searching for a tool that would help me to feed articles for me to my website and i found it here and i think its very useful s... • Jeff Starr: Hi Abbott, I have read many reports of this error happening with WordPress in a variety of scenarios: plugins, upgrading, auto-upgrad... • Abbott: ColdForm installs and activates no problem, but when I try to access the options/setup page under the settings menu it basically kick... • Jeff Starr: @Baruch: you're welcome :)... • Baruch: Jeff, you are a genius!:)) The script is working flawlessly now! I'm so relieved! Thank you sooo much for taking the time to twe... • Sebastian: @ HeadY Besten Dank! It works! I am using: mootools/1.2.3/mootools-yui- compressed.js and I took a new 'more' from the mootools ... • HeadY: @15 ill do this, check if you have the right more version, oder check if it works with the 1.2.2 Core from Google: http://ajax.goog...

Read more recent comments.. Subscribe to Content Recent Activity

Recent Articles

• Tell Google to Not Index Certain Parts of Your Page • Sexy HTML List Tricks • The 5-Minute CSS Mobile Makeover • The Power of HTML 5 and CSS 3 • Display Random Posts from Specific Tags or Categories • HTAccess Password-Protection Tricks • Another Boring Personal Update

Popular Posts

• Wireless Internet: BlackBerry Curve as Bluetooth Modem for OS-X Mac • Category LiveBookmarks Plus • The Perishable Press 4G Blacklist • WordPress Plugin: Contact Coldform • Tell the Cows • Stupid htaccess Tricks • BlogStats PCC Plugin • The htaccess Rules for all WordPress Permalinks • Important Security Fix for WordPress

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 24 of 25

• Maximum and Minimum Height and Width in Internet Explorer

Recent Updates

• Wireless Internet: BlackBerry Curve as Bluetooth Modem for OS-X Mac Edited: August 29, 2009 • Tell Google to Not Index Certain Parts of Your Page Edited: August 24, 2009 • Open Casket Edited: August 23, 2009

Random Articles

• Eight Ways to Blacklist with Apache’s mod_rewrite From: February 03, 2009 • Have You Seen Endgame? From: January 30, 2008 • The Deluxe One-Minute Dofollow WordPress Upgrade From: September 10, 2007

Explore the Archives..

Validation

Far from perfect..

• XHTML Validation • CSS Validation • RSS Validation • WCAG Validation • AAA Credentials • Accessibility

Switch Themes

Customize the site..

• Bare bones • Classic theme • Dark minimalism • Light minimalism • New minimalism • Current theme • More themes..

Perishable Sites

Business and pleasure..

• Monzilla Media • mindfeed.org • Dead Letter Art

9/4/2009 How to Import and Display RSS Feeds in WordPress • Perishable Press Page 25 of 25

Networked

Connected elsewhere..

• 9rules Network • Perishable Press • Return to Top

Friends

Through thick and thin..

• Donace • Rick Beckman • Thane Champie • Chris Coyier • Stephen Cronin • Will Macc • Terry Mun • Louis Pontoise • Graham Smith • Kim Woodbridge

Copyright © 2005—2009 Perishable Press • All Rights Reserved • Full credits • Site Design by Monzilla Media

9/4/2009