Merging Two WordPress Blogs

On Wednesday I merged both my Tech blog and AIS blog on this domain into one. Mainly because the AIS one just wasn’t getting many updates to it and I chat about web development and business topics on my Tech blog anyway which are probably of interest to both blogs anyhow.

The merge itself wasn’t too hard however to ensure everything was done correctly and that I didn’t affect the live site too much, I did the merge offline on my own computer instead of on the live server. I could have installed WordPress in a directory and done the same so if you do every need to try this out and don’t want to install a web server then you can do that too.

Create a Test Site

First off I created a fresh install of WordPress on my computer (or you could do this in a directory on your server). I then exported a copy of my live WordPress database via phpMyAdmin for my main blog ie. the one with more posts in it and used this to replace the freshly installed database on my computer. I also added my live theme to the second version too, not to forget the plugins in use. So this way I’d have my live site running in a separate version but completely the same.

Next step was to use the export function in my second blog (my AIS one) and export all the posts, pages, categories and comments. Although it says it exports links too, I found that it didn’t, or it didn’t import them anyhow. The export creates an XML file, and then in my first blog (on the test version) I went into the admin and used the import from WordPress option (under Manage) and imported the XML file.

Bulk Manage your Categories

So at this point I had all of my posts from the second site merged with the main site, however I also had double the categories. Next job was to move most of the posts into a single category called AIS. Usually this means opening up each individual post and changing its category, not something I fancied doing with over 200 posts! So my first stop was the database, however with the way WordPress now assigns posts to categories it’s a fairly complicated system to simply change all posts assigned to category X to be assigned to category Y (which is what I could have done before WordPress 2.3!). After a bit of searching around I came across a plugin called Batch Categories which allows you to manage your posts in various categories in bulk. You can remove selected posts or add selected posts to categories, or do other stuff such as assign tags etc. it’s a great plugin for anyone looking to alter their category or tag system. I then had to manually add in my links off my other site as they hadn’t imported for some reason, but this didn’t take too long.

Put up Redirects

This then gave me a merged site and all my posts off my AIS blog in one category. I could probably split them up a little but I think they all fit fine in there. After a couple of minor alterations to my theme, the next job was just to sort out my htaccess file. Before, both my blogs were in their own directory and now I’ve moved the blog to the root. With permalinks I could just add in a couple of redirects that just removed the directory name from the URL ie.

.htaccess redirects
  • RedirectMatch permanent ^/blog/?(.*)$$1
  • RedirectMatch permanent ^/ais/?(.*)$$1

This will then just remove the /blog or /ais from the URL and if anything is on the end of the URL (eg. the link to a specific post) it will get added to the end of the domain so becomes

Also, not to forget that I’ve removed a number of categories from my AIS site so I need to ensure these are redirected through to the correct category eg.

.htaccess category redirect
  • RedirectMatch permanent ^/category/product-selling/?$

Of course I’ll still continue to keep an eye on my 404 errors over the next month in case I’ve missed anything.

Upload the new site

Then it was time to put the new site online. Easiest option here was to lock the domain down so that the general public would just get a login box. It saves anything getting triggered and breaking whilst moving everything around. Once this was in place I copied the entire content of my blog directory into the root directory on the server. I also removed the old index.php file and my old htaccess file to avoid confusion. I then removed my live WordPress database and replaced it with the new database from my test site, which now holds the merged sites. Then I added the new htaccess file and tested the site and the permalinks to ensure everything worked as it should. Once everything appeared fine I removed my old AIS site and database.

Don’t forget the Feeds!

To ensure I didn’t lose my subscribers to my RSS feeds I logged into Feedburner and updated all 3 feeds to use the new feed address. This way anyone subscribing to any of the original 3 feeds available will now get the correct feed without having to change anything themselves. of course I risk losing a couple of subscribers who don’t want to see anything from my other blog and just read my AIS posts, which they can do so by visiting my AIS category once in a while, but I think and hope that I write other posts that may be of interest to them too 😉 If necessary it is possible to just receive the feed for the AIS posts directly from the category, if you really want to update your feed reader 🙂

So hopefully something in all of that may be of use to others. If nothing else, the Batch Categories plugin is worth making a note of!

Note: Annoyingly though it seems that the import of the XML file from the second blog has lost my line breaks in both posts and comments and replace them with a single or double ‘n’.

You may also like...