Subdomain Based Multilingual WordPress

Some days ago I wrote I was trying to setup this bilingual blog using different database tables but the same WordPress installation. This way I only have to upgrade my WordPress installation and plugins once. But I can still use different themes / language per subdomain if I want to do so.(and that’s great for experimenting).

Having this done is pretty easy. You have to change the part where you define your table_prefix in your config.php file to something similar to the code below.


$subdomain = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], '.'));
if ($subdomain == 'en')
{
$table_prefix = 'en_';
}
else
{
$table_prefix = 'wp_';
}

In this case I presume you want to link the subdomain ‘en’ to $talbe_prefix = ‘en_’ like I did for this website. If you want to use ‘english’ as a subdomain and you used ‘wp2_’ as table_prefix, of course you’ll have to use those values.

Now I only need to find a plugin that is able to scan the wp_content/uploads/ directory so I can use the same media in both blogs.

Golb’s Recommended WordPress Plugins

Simple CAPTCHA. Protect your blog against SPAM bots. Simple CAPTCHA doens’t require any coding and works extremely well and is easy to use. The big advantage of Simple CAPTCHA above Askimet is that it doesn’t give the SPAM bots the idea they could post something. After some atempts the bots will stop attacking you and will leave your blog aside. This makes a big difference on the server traffic and load.

Google XML Sitemaps: creates automatically a XML sitemap of your WordPress blog. These sitemaps can be used in Google’s “Webmasters Tools”, the ideal tool to monitor your sites healthiness.

Feedburner FeedSmith. First create an account on Feedburner.com, then install Feedburner FeedSmith plugin on your blog. In the plugin settings, fill in the address of your newly created Feedburner RSS et voila. You’re done. All you RSS feed subscribers will be forwarded to the Feedburner RSS. No coding is needed. The great thing about Feedburner is that you can have a better view on your RSS subscribers.

Yet Another Related Post Plugin. In an attempt to get a higher click-through rate I installed this plugin. Based on the tags, categories, url and titles, related posts are shown under each single page post.

WordPress Database Backup. Last but not least: a decent backup tool. You can choose to backup all your WordPress tables plus all other tables inside your database. Manually or automatically. You can store the backups on your server or you can use the mailing option. Works perfect.

Multilanguage WordPress Installation

WordPress is great, it’s easy to use and it does what it’s supposed to. Except for multilingual support. I already have a blog in Dutch: www.golb.be, and now I started another one in English (you’re looking at it). One way I could do this was to set up a sub domain and to install another WordPress installation in there.

Wouldn’t it be nice if WordPress would support this in the standard installation? I’m not looking for software or a plugin to translate each and every blogpost I make, but I would appreciate it if it would be possible to administrate both blogs from the same admin panel. If you have two separate installations, and two separate databases, you can’t easily reuse your media in your content folder and you have to upgrade your installations separately. Although the last part could be solved by making the config.php file sub domain aware. This option I still have to experiment with.

Wouldn’t it be nice if you could simply indicate the sub domain you would like the post to show up? I configured my server in such a way that all sub domains are pointing to www, but without losing the sub domain name in the URL. If the WordPress software would be smart enough to see which sub domain is used and to show only the posts related to that subdomain, that would be great.

I don’t think this is difficult to implement, and I could do this myself, but then I have to alter the WordPress database and I’m not sure it will survive future upgrades.

What do we need to change? Three things: a piece op php code to query only the posts for the relevant sub domain, a piece of php code to make the option available to save a post for a specific subdomain and the MySQL db to keep track which posts belong to which subdomain. Can’t be that difficult.

So why isn’t this not yet implemented? Probably because not everybody has full control over his web server and probably because not many people are asking for it. But can you imagine the benefit of it? Not only for multilingual websites, but also for people who want to make separate blogs per type of interest. Maybe even on different domains…