I broke one of my own golden rules yesterday and launched a new website for a long term client on a Friday afternoon.
Of course, doing this on a Friday, everything went horribly wrong just to remind me why I created the rule to never make any kind of technical changes to anything on a Friday afternoon.
Widgetkit Problems Moving WordPress to another directory
The exact problem I had was with the Yootheme.com Widgetkit set of plugins. Widgetkit is very cool and it includes a range of galleries and slideshows that you can drop into your posts with a convenient shortcode. Great. But, on this job the client was adding their own content and working in a sub directory of the main site. So, when we came to launch the site, we ran the usual WordPress migration SQL scripts and assumed everything would be tickety-boo. We were wrong. Dead wrong.
Broken Link Hell
The site was mostly fine but anything linked from a widgetkit plugin was not working and it was still showing the path to the development site.
WidgetKit stores it’s data in the WP_Posts table but for some reason my standard WordPress Migration queries had not picked these URLs up.
UPDATE wp_options SET option_value = replace(option_value, 'OLDSITE', 'NEWSITE') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'OLDSITE','NEWSITE');
UPDATE wp_posts SET post_content = replace(post_content, 'OLDSITE', 'NEWSITE');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'OLDSITE', 'NEWSITE');
So, I kept on digging around and discovered why: Widgetkit uses escape characters in the URLs so:
http://www.url.co.uk/
becomes
http://www.url.co.uk/
Okay, so, lets just query the database and use my same old posts update query but include the escape characters so:
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl.co.uk', 'http://www.newurl.co.uk');
Simple, right? Nope. Unfortunately not. No dice.
The problem? Well, you need to escape the escape characters in the SQL query to make this work so….
http://www.url.co.uk
Becomes
http://www.url.co.uk
So, your final bit of SQL required here is:
UPDATE wp_posts SET post_content = replace(post_content, 'http:\/\/www.oldurl.co.uk', 'http:\/\/www.newurl.co.uk');
All good fun!
Updating Widgetkit in the WordPress Database
For those of you still with me and that find yourself in this dilemma with some widgetkit errors that you want to bulk update then just keep in mind that the URLs in the WP_Posts table use as an escape character and that you then have to escape the escape character in your MySQL query with another giving us before any /.
In possibly simpler terms, replace all instances of / with \/ when searching for and updating URLs in widgetkit posts.
Hope this helps someone and please share or reference or share this post if you found it useful.
2 Responses
Thanks! I found myself in EXACTLY this situation — on a Friday, no less, but I did my launch in the wee hours.
Hey Barb, glad it helped. Certainly threw me for a loop when I first ran through my usual (simple) wordpress migration launch procedure. 🙂