Header 1
endereçoheading 2
cabeçalho 3
cabeçalho 4
nenhum
esquerda
direita
centralizado
pré-formatados
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.
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!
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
The XmlTextReader class is not the most intuitive class to work with, as the methods and properties are very low level. While the XmlTextReader class is rich in properties and methods, I’ve found that most of what it provides isn’t necessary for the average day-to-day job. So, in this article, I’m going to present a moderately thin wrapper class for the XmlTextReader, which should be a helpful guide to using the XmlTextReader for programmers not familiar with this class. This article is also an introduction to a variety of other disciplines that I feel a beginner should be aware of–code commenting, abstraction and architecture, and unit tests. So hopefully there’s something here for everybody!
To summarize from this site:
XmlTextReader if you need performance without schema validation or XPath/XSLT servicesXmlDocument if you need XPath services or need to update the xmlNaturally, XmlTextReader is closer to the XML. It is a forward only reader, meaning that you can’t go backwards. Contrast this with the XmlDocument class, which pulls in the entire document and allows you to random-access the XML tree. The XmlTextReader supports streams and therefore should reduce memory requirements for very large documents.
Another advantage of the XmlTextReader is that it provides line and character position information, which can be very useful diagnostic information when there’s a problem with the XML.
There’s a core set of features in XML that I want my reader to support:
Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!
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.