Batch import WordPress posts to a specific category

WordPress is rather primitive when it comes to partial migrations. It is easy to move the whole of your blog but not to import your posts into a particular category of another blog. For example, if you have an “Office” blog and you need to transfer its posts and categories and tags to the “Office” category of your general “Microsoft” blog, you will find it very difficult. WordPress importer won’t let you read your backup file to select which posts to import to which category.

Here is what you can do to solve this problem by replicating first the categories hierarchy of your Source blog as a child of a category of the Destination blog. You need to install the Bulk Category plugin in both the Source and Destination blogs.

First create in the Source blog a category with the same name as the name of the category in the Destination blog. To use the example above, create an “Office” category in the Source blog. Then edit each of your top-level categories of your Source blog (e.g. the “Access” category, “Word”, “Power Point”, etc) to have the new “Office” category as their parent. Use the Bulk Category plugin to export your category tree to a csv file. Use the same plugin in the Destination blog to replicate this structure as a child of the “Office” category of the Destination blog. You need to edit the csv file manually to delete the top level category, since it already exists in the Destination blog.

To use the example above, if you are importing an Office blog into the Office category of a “Microsoft” blog, open the csv file and delete just the single “Office::office” line, since the top level, “Office”, category already exists in the “Microsoft” blog. Make sure all the other categories mentioned in your csv file that Bulk Category created are defined as children of the Office category. Then use the “Add Categories” feature of the Bulk Category plugin to import in the Destination blog the structure of your Source blog. Since the Office category already exists and all the imported categories are defined as sub-categories of Office, the old structure will have your existing Office category as its parent.

Use the export tool of WordPress to export an xml file with your blog posts from the Source blog. In the Destination blog use WordPress importer to import your posts to the Destination blog. WordPress will assign all of your posts automatically to the Office category of the Destination blog and to each sub-category already created in the Destination blog.