How To Hack The WordPress Blogroll Importer To Recognize Categories From Your Feed Reader
Do you let your WordPress blogroll go stale because importing and recategorizing hundreds of your current reads is too much of a chore? I do. Although WordPress will import an OPML file of all my feeds, the importer is only capable of importing my links into a single category. If you’ve ever used this function to import a large number of links spread over several categories, you know that having to manually move each individual link to the correct category is enough of a chore that it’s easier to let your links go stale.
Yesterday, I spent the entire day working on the issue that stood between me and blogroll full of fresh, categorized links. While I know that it’s bad form to edit core WordPress files, the result of my effort is a hacked version of link-import.php that makes WordPress (v. 2.3.3) recognize categories when importing an OPML file. I tested it with a few variations exported from both Google Reader and Thunderbird, and it seems to work pretty well.
What This Hack Will Do
- If you only have one category of links in your feed reader, everything should work the same as it did before.
- If you keep your feeds in multiple folders in your feed reader, the importer will check to see if each folder name is an existing category in the WordPress Links Manager. If it is, all the links from that folder get imported into the corresponding category. If there is no identically named link category, the links get dropped in the default category.
- When it’s finished, the importer notifies you of which folder names were not found so you can either create the missing categories, or check your spelling.
What This Hack Will Not Do:
- Anything secretive or nefarious. That is not my thing.
- It will not create new categories based on the folders from your feed reader automatically, because I thought that it would be safer to keep control over category creation as a manual process.
- It does not correct bad spellres. The category / folder match is case and space sensitive.
- It doesn’t handle anything beyond one level of folders. If you break down your feeds into more than one level of folders, the importer isn’t going to recognize them.
- It won’t hang around after you upgrade WordPress. This is a hack and not an official WordPress file, so it will get overwritten the next time you upgrade.
- It will not give you nunchuck or bow hunting skills, nor make you more attractive to the opposite sex.
How To Use This Hack:
- Download and unzip the hacked link-import.php
- Go to
[WordPress install folder]\wp-admin\ - Rename
link-import.phptolink-import.old - Upload the new
link-import.phpinto the directory.
How to Remove This Hack:
- Go to
[WordPress install folder]\wp-admin\ - Delete
link-import.php - Rename
link-import.oldtolink-import.php
How to Import Your Blogroll Into WordPress
- Export your list of feeds from your favorite feed reader to an OPML file.
- Go to Blogroll / Import Links in your WordPress admin panel.
- Input the location of your OPML file into the input box.
- Select a category from the dropdown menu to use as a default category. You may want to create a category called “uncategorized” to catch the missed links.
- Click the Import OPML File button.
- Check the results for any corrections that need to be made to your OPML file and re-import, if necessary.
If you have any suggestions or notice any bugs with the file, leave a comment and I’ll see what I can do to address them.
Share, Bookmark, or E-Mail This Article
March 25th, 2008 at 11:58 am
May I know $names used on Line 110 is used for? Where it was created or assigned value?
October 17th, 2008 at 3:22 pm
This type of importing SHOULD be in WordPress by default. I liked your hack, but it doesn’t work for WP 2.6. Since you didn’t add too much to the file, I played around with it until I got it working.
That’s right, I have a modified version of your hack that works on WordPress 2.6.
I have not tested it for backwards compatibility (it probably breaks). But yours works up to 2.3 so that is fine.
If you want it so you can check it out and potentially post here, send me an email.
There must be other people out there who really want this functionality (not just us hehe)
November 12th, 2008 at 12:51 pm
It actually looks like the first guy who left a comment (Jaymin) took this idea, enhanced it, and submitted his code to the WordPress Trac. I wish it was going to be added to 2.7 but it sounds like it won’t be considered until version 2.8.
Still, code is a big step forward for the WordPress Links (blogroll) import / export functionality.
Export & import blogroll with categories
While searching the Trac, I also found an old (still open) ticket concerning why the link ‘export’ OPML page is so hidden.
OPML link kept a secret
On a side note, I find it kind of humorous that in my research into this matter it seems like just the 3 of us really seem to care. Care enough to have coded any enhancements. I’m sure I’m wrong but….still funny.
April 29th, 2009 at 1:38 am
I made a plugin for WP 2.7+ to add this functionality. It doesn’t replace or modify the OPML importer, but it ADDS a new one that can handle categories.
Import Blogroll With Categories
If there is a demand for it, I can try to make it backwards compatible with older versions of WordPress.