Posts Tagged ‘Wordpress’

WordPress iPad App – Failed Login Problem

// December 7th, 2010 // 2 Comments » // Web

After a considerable time failing to add this blog to the WordPress iPad app, I finally spotted a comment on a forum pointing out that it requires XML-RPC to work.  So if you are having the same intensely frustrating rejections every time you try and add your site, you fix it like this:

  1. Log in to the admin console via the web
  2. Click on Writing (under Settings)
  3. At the bottom of the page, check the XML-RPC checkbox and hit Save.

Now when you start up the app it should be able to authenticate you.

This is the kind of bug that is pretty unneccessary, and will doubtless put off a lot of new users.  How hard is it to point out such a basic requirement whenever the app fails to find an XML-RPC uri active on the site?

After 2 mins of using the app I’ve been dumped out by crashes twice and find a lot of  the setup, but will persevere as I’d love to be able to draft blog posts on the bus home and save them offline…

Portfolio: Corzano e Paterno.com

// January 26th, 2010 // No Comments » // Web

A trilingual WordPress site built for the Corzano e Paterno farm in Tuscany, producing prize winning wines, olive oil and cheeses. It’s an old farm in the hills that used to be owned by the Machievellis, which now has a lovely set of guest houses you can rent through the site.

Corzano e Paterno site - wine page

Picasa photo album integration:

Corzano e Paterno site - example photo album

The site features a blog, press clippings, downloads of publications which have featured the farm’s wines, and other news:

Corzano e Paterno site - news page

This is integrated into a database of each year’s wines and cheeses:

Corzano e Paterno site - cheese page

Portfolio: Masabi Rebrand

// December 10th, 2009 // No Comments » // Mobile, Web

My company has gone through a complete transition over the second half of 2009, moving from a general mobile application consultancy to a product-based transport ticketing vendor. This new focus merited a total branding overhaul as our old look, with its black background, was more appropriate for our legacy marketing and gaming background.

The new font and colour scheme were designed to evoke the feel of the old British Rail branding, whilst the logo resembles the front of an Intercity train:

Masabi's new logo - The Ticket Machine In Your Pocket

The new tagline – “The Ticket Machine In Your Pocket” – came out of a brainstorming session during the excellent g2i (Gateway to Investment) course we took part in, which I would highly recommend to anyone interested in grooming their company for funding, or just understanding when a startup needs funds and what to expect from investors. It’s sponsored by the London Development Authority but run by industry professionals, offering top quality advice and opportunities where all participant’s interests are aligned – far better than the fee-based ‘advice’ and ‘connections’ that are so easy to come by.

The front page embeds a video of the product in action which really explains the underlying concept nicely – the photos I took during the video shoot now form a great resource of imagery for company documents and presentations:

The site structure is intentionally simple: it features simple product tours aimed at Passengers and Train Operating Companies:

The news section manages press releases and external coverage, alongside a social media feed integrating the company’s Flickr, Twitter, YouTube and SlideShare channels:

There is also a live feed showing the next event Masabi will be presenting at driven by our Google-based events calendar, with an integrated view on the site:

The company blog was migrated over from the Blogger account of the old site; a redirect plugin was set up to ensure legacy URLs continued to work:

The site also has all the obvious bells and whistles like Google Maps integration to find the office, and directions from the nearest tube stations etc:

Migrating Blogger to WordPress – Easy 301 Permalink Redirects

// October 25th, 2009 // 1 Comment » // Dev, Web

I’ve been moving the Masabi web site and blog onto WordPress, from a combination of static web content and a blog driven by Blogger. WordPress has a great import function to move the posts across, which does most of the initial work for you.

However, WordPress won’t by itself set up redirects for the old Blogger to new WordPress permalinks. The two platforms shrink post titles to URLs differently, so it’s not as simple as matching WordPress permalink structures to Blogger’s under the Settings.

I did see one plugin which was supposed to migrate Blogger permalinks automatically, but it didn’t work and also didn’t cover the full scope I needed – I also have legacy static html links to remap into a totally different site structure. To achieve this I turned to the excellent Redirection plugin from John Godley.

Getting Inside The Database

The plugin allows you to manually set up redirects with a very friendly interface, but there’s no fun migrating 70 blog posts by hand.  This is where SQL can come to our rescue!

VERY IMPORTANT: take a full backup of your database before you start messing around with SQL.  In theory this is a pretty low risk operation, but, you never know!

The Blogger import utility saves custom fields for every imported post; the Blogger permalink is held in the blogger_permalink field; custom fields are stored on the post_meta table with an obvious ID based backlink to the original table.  This makes one half of the mapping very easy to set up.

The other half is slightly more subtle, because WordPress permalinks are not actually stored on the wp_posts table. Every post does have a GUID, but this is based on what its permalink was when you did the import – and if you imported when you created the blog and set your WordPress permalinks later, this will not reflect the post’s current permalink URI. Ideally we’d like the 301 to point to the real end URI, so we need to get a little creative and rebuild the permalink in the way WordPress does it, from the post metadata.

My permalink structure looks like this:
YYYY/MM/DD/title/

This can be rebuilt using the following string manipulation in SQL:
CONCAT('/',YEAR(post_date),'/',LPAD(MONTH(post_date),2,'0'),'/',LPAD(DAY(post_date),2,'0'),'/',post_name,'/')

Notes on the SQL functions:

  • CONCAT just combines all of its arguments together into a single string;
  • LPAD is used to pad the left of the string with 0s, as the month and day are always 2 digits long;
  • YEAR, MONTH and DAY extract the relevant fields from the post’s creation date/time.

Given this data, we can easily create an automatic import SQL statement for moving the data across:

INSERT INTO wp_redirection_items (url,action_data,regex,group_id,status,action_type,action_code,match_type,last_access,position)
SELECT M.meta_value AS url,CONCAT('/',YEAR(P.post_date),'/',LPAD(MONTH(P.post_date),2,'0'),'/',LPAD(DAY(P.post_date),2,'0'),'/',P.post_name,'/') AS action_data,0 AS regex,1 AS group_id,'enabled' AS status,'url' AS action_type,301 AS action_code,'url' AS match_type, 0 AS last_access, 69 as position
FROM wp_postmeta M, wp_posts P
WHERE M.meta_key='blogger_permalink' AND M.post_id=P.ID AND P.post_status='publish';

Run this through PHPMyAdmin, refresh the Redirection admin page, and you should now find that all of your permalinks have been moved across. Note that we set the position field to an arbitrary constant, here 69, so we can easily delete the inserted rows if we messed up and then try again, without upsetting any other redirects already set up.

E-Mail Not Working In PHP / WordPress? It May Be CPanel MX Records…

// October 20th, 2009 // No Comments » // Web

I host a few domains through Nativespace and Host Gator (which both use the CPanel interface), and all of them have had one flaw – PHP apps like WordPress, Drupal, and also WordPress plugins like the Dagon Design Mailer Script have never been able to send email.  It’s quite hard to track down this kind of error yourself on a managed host with a web UI so in the past I’d not worried about it, but finally it came time to solve it (or rather get Ben to solve it, but I’ll write about it so others don’t have to go through the hard work)

The Problem: CPanel’s Broken MX Assumptions

Note: you can ignore this section if you don’t care why the problem occurs, and just want a fix!

It transpires that the problem occurs when the domain being hosted is registered through some other provider, which therefore runs the domain’s DNS and MX records.  MX records tell the world how your domain runs its e-mail.

Rather than do a proper MX lookup for sending e-mail, CPanel just assumes it runs the domain’s MX records and looks up in its own local configuration.  This would be fine if it did run the domain’s e-mail, but in these instances it doesn’t and therefore the e-mail ends up falling into a black hole.  Why the authors chose to do this is uncertain, but it is easy to fix.

The Fix: Redundanct Configuration

First, find the MX Entry icon in the Mail section of the CPanel front page:

CPanel's MX Entry icon

Click on it to see CPanel’s configuration for your domain.  The default looks something like this:

CPanel's default MX configuration

Many of my domains use the free Google Apps product to offer GMail accounts that work with the domain (ie. a GMail inbox tied to an @masochismtango.com address).  Here is the CPanel configuration you need if your domain does the same – if not, you’ll need to check your MX records with your domain registrar to find the right configuration to enter here.

Warning: this solution only works if you know the real MX records for the domain! If you don’t you could mess things up.  Remember it may be easier to just file a support ticket – I’m not taking responsibility if you mess this up!

First, add the correct MX configuration for the domain:

MX configuration for a domain with Google Apps GMail

For GMail, you can get away with just adding a couple of entries, at priority 1 and 5. Then, delete the old priority 0 entry which CPanel started with to leave just the real configuration:

MX configuration for a domain with Google Apps GMail

Now you’re done – hopefully your emails should instantly start working!

Multilingual WordPress Sites

// June 7th, 2009 // No Comments » // Web

Over the last month I’ve been building a tri-lingual site for an excellent little farm in Tuscany, Corzano e Paterno, where among other things they make prize winning cheeses, olive oil and wines (all of which I recommend trying whilst staying in one of their villas – really, it’s great!)

The one requirement that caused me the biggest headache was the need to handle three languages.  There are quite a few plugins which can handle two, but only a handful which manage three or more and almost all aren’t actually that easy to use and/or reliable.  In the end, after much experimentation, I settled on the excellent qTranslate which really beat all of the others hands down. Highly recommended.

qTranslate integrates nicely into the WordPress page and post admin UI, offering multiple header fields and extra tabs for each language you want to add:

qTranslate WordPress plugin's Admin UI

For standard functions, everything is great and works seamlessly.  However if you need to directly access the contents of a field in a post/page object, things will look a bit weird:

<?php echo($single->post_title); ?>

will look on the page like:

EnglishItalianoDeutsch

generating the following actual markup:

<!--:en-->English<!--:--><!--:it-->Italiano<!--:--><!--:de-->Deutsch<!--:-->

So what to do? Well, fortunately, we can just hijack a function hat qTranslate uses itself to resolve the current translation for any field – replace the :

<?php echo(qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($single->post_title)); ?>

It’s that simple – wrap that function around any multilingual property you need to read, and qTranslate will do all the heavy lifting for you!

Portfolio: Temono web site

// November 15th, 2008 // No Comments » // Web

Just completed a rebrand for Telecomms PR outfit Temono, including a WordPress-based web site, Powerpoint .pot template and related collateral:

Temono web site - screenshot

The site features a blog, customer case studies and all of the standard static content you would expect.