WordPress Database & WidgetKit – Problems & Solutions

WordPress LogoI 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:




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….




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

Leave a Reply

Your email address will not be published. Required fields are marked *

Free Digital Marketing Review

Book a call with Marcus Miller to learn how to generate more traffic, leads and sales.

1. Review your current marketing
2. Identify your key opportunities
3. How to improve results & cut costs!

Put over 20 years of marketing experience to work for your business today.