Part One – Dissecting the WordPress Import/Export Format: Categories
I’m working hard in my spare time on transitioning my longest running project – DVD review site UpcomingDiscs.com, which I co-own – from hand-built CMS to WordPress.
What I’m trying to do is move 3000+ reviews (including comments, screenshots, rankings, and DVD metadata) from my clunky, work-around riddled data architecture to nice clean blog posts. What this means is shoehorning the complete contents of UpcomingDiscs into the WordPress Import/Export format so that I can pull the whole site into a WordPress install – i.e.: I’ll be generating a fake WordPress export file from UpcomingDiscs and “importing” it into a real WordPress install. This is no simple task given the legacy complexities of UpcomingDiscs – but as I’m discovering with a lot of investigation, can certainly be done.
So – my intent is to share that knowledge as I gain it – starting today with the WordPress Import/Export format for Categories.
First – a little background.
- The WordPress Import/Export format is at its simplest a modified RSS format, including a bunch of extra XML tags for WordPress-y stuff not covered in the basic spec. Here’s an example.
- An Import/Export file includes all of the content from a WordPress install – categories, posts, comments, blogroll, dates, times, authors, post-settings, and so on. In my case, not all of this stuff is needed.
- The best way to figure out how to get certain things in the WordPress Export format is to set up a dummy WordPress install, create fake blog posts that include whatever you’re trying to figure out, and then “Export” it and reverse engineer the WordPress XML.
Categories
Reviews on UpcomingDiscs are categorized in a wide variety of ways – take a look. Audio. Video. Box set. Genre. Etc. How does one get those categories into WordPress, and link reviews-converted-to-posts to them properly?
To begin with, WordPress Import/Export has a set of Category tags that describe a category, as follows:
<wp:category>
<wp:category_nicename></wp:category_nicename>
<wp:category_parent></wp:category_parent>
<wp:posts_private>0</wp:posts_private>
<wp:links_private>0</wp:links_private>
<wp:cat_name><![CDATA[]]></wp:cat_name>
</wp:category>
category_nicename
This is the URL-friendly version of your category name. See the TechFold “Site Profiles” page URL for example – notice the “site-profiles” which is the “nicename” version of “Site Profiles.”
You can leave this blank, and WordPress will automatically create a “nicename” based on the actual “cat_name” you specify later-on (see below).
Note: If a category is a “parent” (see next point!) you do need to create a nicename for it.
category_parent
If a given category is actually a sub-category in a hierarchial organization, it belongs to a “parent” – for example, in the case of “Audio > Dolby Digital 5.1,” Audio is the parent, and Dolby Digital 5.1 is the sub-category.
In the case of a sub-category, you have to enter the “nicename” of the category that it belongs to here, in the “category_parent” tag. If you do so, WordPress will nicely nest your categories. If not, they’re all at the same level, and your heirarchy is out the window.
That’s why – as noted above – you need to create a nicename for categories that are parents – so that you can enter it into the “category_parent” tag of sub-categories to link them all up.
posts_private and links_private
I haven’t actually experimented with these yet; posts_private means that posts in this category are set as “private,” links_private I’m not sure about. Assuming you’re not making use of either of these features, leave them with “0″ values.
cat_name
This is the good one: “cat_name” is where you store the full-text name of your category, including all punctuation, spaces, accents, crazy characters, or whatever. WordPress will take that and use it as the visible title for your Category, and will create a URL-friendly “nicename” from it as well.
Important: Your cat_name needs to be enclosed in the CDATA delimiters. i.e.: “
Summary
That’s it in a nutshell. Categories are easy, and WordPress makes it easy to import and preserve your hierarchy. Here’s a few examples of completed categories for reference:
A simple category with no hierarchial relationships:
<wp:category>
<wp:category_nicename></wp:category_nicename>
<wp:category_parent></wp:category_parent>
<wp:posts_private>0</wp:posts_private>
<wp:links_private>0</wp:links_private>
<wp:cat_name><![CDATA[My Favorite Movies]]></wp:cat_name>
</wp:category>
A simple category that I’m setting up to be a parent:
<wp:category>
<wp:category_nicename>my-favorite-movies</wp:category_nicename>
<wp:category_parent></wp:category_parent>
<wp:posts_private>0</wp:posts_private>
<wp:links_private>0</wp:links_private>
<wp:cat_name><![CDATA[My Favorite Movies]]></wp:cat_name>
</wp:category>
A sub-category, in this case for my favorite Science Fiction movies, which belongs to the “My Favorite Movies” category:
<wp:category>
<wp:category_nicename></wp:category_nicename>
<wp:category_parent>my-favorite-movies</wp:category_parent>
<wp:posts_private>0</wp:posts_private>
<wp:links_private>0</wp:links_private>
<wp:cat_name><![CDATA[Science Fiction]]></wp:cat_name>
</wp:category>
Make sense? Got questions? Drop them in comments!
blogging, export, import, wordpress xml
If you enjoyed this post, make sure you subscribe to my RSS feed!
Related Posts
UpcomingDiscs.com: WordPress conversion complete
WordPress Expert – Part Two: Doing cool stuff with Custom Fields
How WordPress.com Stays Spam Free
WordPress Tip – Schedule your posts
Testing WordPress Geotagging Plugin
8 Responses to “Part One – Dissecting the WordPress Import/Export Format: Categories”
Tags: tag teste 1, tag teste 2, tag teste 3
Sounds like a lot of work… I did not have to work this hard for my transition to WordPress, you’ll soon read why
[…] Part One – Category Hierarchies in the WXR Import/Export format Part Two – Custom Fields […]
Stubmled by your blog while searching for the same. I am trying to do same thing. Thanks for the input.Do you know if you can add HTML to these RSS Feeds? I have not been able to make it work.Thanks for sharing your experience again, it was helpful.
Priyank
[…] Part One – Dissecting the WordPress Import/Export Format: Categories « TechFold – Bold tech & w… Reference post via Rusty. He’s going to help me finally import my old custom database into WordPress! wordpress xml howto tutorial […]
[…] Part One – Dissecting the WordPress Import/Export Format: Categories « TechFold – Bold tech & w… Reference post via Rusty. He’s going to help me finally import my old custom database into WordPress! wordpress xml howto tutorial […]
Thanks for documenting this so nicely. I used it to create nested categories of the largest cities in the world for a regional blog. Much faster (and more interesting) than typing them in by hand!
I do not believe this
Looks quite complicated to me. Maybe it is easier to assign an specific author then export it using wordpress export function.