Categories
Personal Reflections Technology

Converting Tags To Categories In WordPress

Update
Spent the last two days working furiously, integrating more plugins, checking whether they work, throwing exceptions, adding Google AdSense ads, et al. Which reminds me, I wanted to add Yahoo! Publisher Network ads – apparently, they pay more, allow you to receive payments via PayPal, and even let you add ads to PDF files and RSS feeds – BUT, and this a big pain in the butt, they want US-based publishers only with predominantly US-based traffic (otherwise, they even ban people…brr).

The Error
One problem I encountered immediately after shifting was using the ‘Convert Categories to Tags’ feature in WordPress. Hadn’t used it on WordPress.com hosted blogs earlier, so I was shocked to see that it DID copy all categories into tags – but at the same time, it deleted those categories too. Hell, those posts didn’t even come under the default category, they simply went off the radar. Since it was a time when I was doing multiple changes to my blog per day, I hadn’t bothered to take a minute-by-minute database backup. I had nothing to fall back to. No problem, I thought, other people must have faced the same problem, and there must be SOME script / plugins out there to handle the conversion of tags back into categories. Surprisingly, there weren’t any.

The Solution
Spent the rest of the day trying to figure out the WordPress database, and a few trials (and a some backup restores later), I hit upon a way to do it.

  1. If there are any existing categories which are named exactly the same as any tags, delete them from Manage > Categories on your WordPress dashboard. The only reason I say this is because it’ll save you a lot of headache while editing the database.
  2. First thing, whenever you do ANY sort of mucking about with databases – back it up! On hosts like GoDaddy, you’ll have an option in your hosting manager to create an SQL dump; otherwise, open up your database manager (on the server) and choose the Export option.
  3. Login to your database manager – which would be phpMyAdmin generally. You’ll need to use the username and password you created initially for this. Generally, the username could be the same as your database name. In case it isn’t, you should’ve written it down, dum dum. :p
  4. Open the database related to WordPress and open the table wp_terms_taxonomy. Check phpMyAdmin’s documentation if you don’t know how. Explaining that is not my job.
  5. Check the box next to any fields which are marked as post_tags, leaving the category and link_category fields as it is. Then, click on the Edit icon at the bottom of the table.
  6. Replace post_tags with the text category in the Edit page. No other change is necessary. Submit the form.
  7. If you run into a MySQL error, of the sort – ‘xx-category already exists’, where ‘xx’ is a number – that has happened because a category and a tag have the same name, and therefore that particular post_tag can’t be renamed to its equivalent category field.

That’s that! Login back to your WordPress dashboard, and you’ll find that all categories have been restored using the tags which were created. Personally, on WordPress, I feel that the categories feature is better than tagging – at least presents a list to choose from! Tagging, on the other hand, doesn’t have auto-complete (by default, at least) on WordPress.

And frankly, WordPress’ categories to tags converter sucks – first, erasing categories, and then not even warning the user before doing so.

Categories
Personal Reflections

Needlessly Messianical Post

At long last, my blog has finally been shifted from sucky Blogger to an amazing open-source project – WordPress. It’s something I’d been thinking of for a long time, and I must say, Jimi did a lot to pester me to shift in the middle of the pre-Boards, that is – but since that wasn’t pushing it far enough, I naturally, decided to shift bang in the middle of the Boards (when I should be studying for the JEE).

Before I go off on a long explanatory post, a few essential things I need to point out.

  • The blog’s been renamed – it’s now called Needlessly Messianic.
  • All old links to Blogger pages WILL work – although it wouldn’t harm you to slowly transition them.
  • There’s this small issue of images being still on Blogger, but I’ll eventually* sort that out. * after all bloody exams are over
  • The old RSS updates feed (http://feeds.feedburner.com/gqb) will be SHUT DOWN within 30 days. The new feed happens to be http://feeds.feedburner.com/ankurbdotinfo – so all those people using feed readers and subscribing to email updates, need to update that – email subscribers need to register again. Sorry folks for the trouble, but that’s inevitable when trying to shift to a better system. However, the old feed will be active for 30 days, so you’ve some time to shift.
  • For all the people who were contributors, sorry, your authorship got changed to my name. Your accounts will have to be added back manually, and if you point out any articles you wrote, I’ll change their authorship for you.
  • Which brings me to another point – NOT ALL POSTS UNDER THE NAME ‘Ankur’ ARE MINE. Thought you should know. Read the point above.

With that out of the way, it’s time for me to get needlessly messianic, and start off on the shift.

Cancelled Hosting
I had my eyes on GoDaddy hosting for quite a while – and after the math exam, went ahead and bought a GoDaddy Economy Shared Hosting plan for four years at a price of ~$165. It absolutely escaped my mind that I actually needed to upgrade my existing free hosting account, rather than buy a new one. Effectively, I just ended up with new hosting I couldn’t attach to any account. I couldn’t FTP my older stuff into the new account without setting it up, and to set it up, I needed the old domain to be free. I could cancel the old account, but then I’d lose all data on it, which I didn’t want. I sent in a request to GoDaddy support to see if they could merge the two accounts, and they said they couldn’t. So I had to cancel the new paid account then – but I need to commend them about this, I got a full refund within three hours of cancelling the account.

Starting Afresh
After the account had been cancelled (and the money safely back into my PayPal account), I initiated the upgrade. First, I bought a one month upgrade to Economy Hosting from GoDaddy – and since March is almost ending, they charged me only for the days left – which comes out to be around $0.83. After that was done, I renewed the same account for a period of four years – and since renewals are cheaper than buying it for that period directly, I had to pay only ~$120! In effect, buy not merging my two accounts, GoDaddy gave me a way to save forty (two) dollars. For $30/year, and the fact that it’s on the world’s largest domain registrar, that turns out to be quite a slick deal.

Matty’s WP
Then started the process of actually shifting my blog. Installing WordPress itself is a breeze, using the GoDaddy Hosting Connection feature – basically, a snazzier version of Fantastico. After it was done, logged in to start importing from Blogger using the built-in import feature in WordPress, and ran into this error:

Connection timed out (110). Secure connection to Google could not be opened.

…which was weird, because the ‘timed out’ came just 10 seconds into loading the page. Tried it quite a few more times, and then it struck me – ‘secure connection could not be opened’. Which means, the probable reason for this error was the fact that I didn’t buy an SSL certificate with my account, and thus it couldn’t connect. I know it shouldn’t happen, that a secure connection is dependent on the originating party – but correct me if I’m wrong, even the client (my server, in this case), needs to have a copy of an SSL certificate to authenticate and complete that.

Anyway, there was an easy way out of this. I used McKenna’s All Weather Haulage to import my Blogger blog into a WordPress.com blog, and then exported everything in a WordPress eXtended RSS (WXR) XML file – which holds all your posts, comments, tags, etc. Got ready to upload that file (which was around 5 MB in size) onto my own account, went to the WXR file import page, and ran into this:

Select file to upload (maximum size 2 MB)

Bid odd, I thought, if WordPress itself had put this limit. WordPress didn’t put a file size limit, I discovered on WordPress support forums – that was something the hosting server could put a limit on. That was followed by workable, but stupid suggestions like ‘split up the XML file manually into smaller chunks within limit’ – in fact, many people went as far as to manually splitting their WXR files into twenty chunks! All that is seriously not needed, because if WP doesn’t limit it, then I could easily solve that myself. If your host allows you access to your php.ini file (like GoDaddy does), you can remedy this yourself. Open up the file for editing, and before the Zend section, add the following line (or if it already exists, modify it):

upload_max_filesize = 420000000

…where, ‘420000000’ is the maximum file size (in bytes, keep that in mind) you want to limit uploads to. Make it as large as you want. However, in case you DO give a large number, also add (or modify) the following line:

input_timeout = 42000

…where ‘42000’ is the time in seconds that you want to keep before the connection times out when doing an upload.

With that out of the way, I could easily upload my WXR file, needless(ly messianic) to say it worked perfectly fine. I was quite surprised though, that (as far as I’d seen), nobody on WordPress support forums had talked of modifying the php.ini file to achieve it – all were of manually splitting XML files (tedious), or ‘contact your hosting company to change the limit for you’ (useless, because practically no hosting company’s customer support knows a fetid dingo’s kidneys about PHP).

Setting Up (Matty’s WP)
That was the easy part, above. Frankly, all the setting up, mucking about with PHP variables etc etc didn’t take more than half an hour. The tedious part comes later, when you try to get all the plugins you want at one place. Without OneClick installer for WordPress – it’s a WordPress plugin itself (and also a Firefox extension), I’m afraid it’d have been even more tedious – FTP files into the requisite folder, extract, reload page, blah blah. What OneClick does is, you add it once using the normal way, and then it adds a page to your WP dashboard. From there, you can directly upload a theme’s / plugin’s archive file, or even specify the URL of the file on some other site (say, the WP Plugins directory), and it handles the rest of the stuff of getting the file, extracting and putting it in the required folder, et al. VERY handy. Kudos to Anirudh Sanjeev, the IIT Kanpur guy who wrote this. Brilliant work. I’ve heard that our very own Lord Vader is a big fan of this guy – and I think Lord Vader got the idea of listening to Amon Amarth from that guy’s blog.

So then, started the merry (and needlessly messianic) task of installing various plugins – mobile site renderer (need to check this works fine if you use cellphone’s own browser, but doesn’t seem to work with Opera Mini), ShareThis (social bookmarking – so that you can now easily Digg articles), feed burning, Snap Previews (Lord Vader hates this), MAPTCHA (CAPTCHA, using math – because Akismet ALWAYS marks my comments as spam), AJAX commenting – and a few more. The difficult part came for deciding the theme. I wanted a three-column theme with main content in the middle, and the two sidebars on either side. Alas, it was too much to ask for. Almost EVERY theme which matched this description was a dark-coloured theme, which I don’t like. Any other three-column themes (which is a majority of the three-column ones) were ones which had both sidebars together on one side, which I don’t like either. And since I’ve a quite a long list of tags, links, and archives to display, I didn’t want a two column one either, for that would make the page needlessly long (and messianic).

Even more irritating was that many of the themes I tried out weren’t ‘widget-ready’ – although I didn’t need that capability in actually, it’s a good thing to have. Most WP themes are, after all, personal themes that authors made for their own blogs and had to release later when pestered by readers for it – so most haven’t really bothered to properly format and indent their code. Thank gawd (again, needlessly messianic) for syntax highlighting and brace matching in Gedit, or I’d be really pissed. Some themes also caused compatibility problems, and I had to reset to default to regain control. Anyway, after hours of searching and debating, I settled for this one – called Fluid Yellow Black. A big thanks to Jimi for searching out and suggesting SO MANY themes. 🙂 Thanks dude.

Needlessly Messianic

A new age has begun – an age of freedom, and democracy – and mores reviews of gory movies with no story. And in case you fucking forgot, THIS…IS…SPARTA!!!