Support » Fixing WordPress » Widgets disappeared after running an SQL query to update links

  • Resolved mslogica


    Hi all,

    This is my first post here, but I’ve been using the forums for years to muddle through my own tech problems. I can’t find a solution to this problem though!

    Today I asked my web host to move my website to a new domain, which they did without problem. The old URL (still online) is The new URL (also online) is

    Having read instructions about moving websites between domains, I knew that I would have to update the URLs within my site once the database had been moved.

    I went on the database once the move had been done, and ran the following three SQL queries through phpMyAdmin. I had read on the web that this would update the links across the whole website:

    UPDATE wp_options SET option_value = REPLACE(option_value, ‘‘, ‘‘)
    UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, ‘‘, ‘‘)
    UPDATE wp_posts SET guid = REPLACE(guid, ‘‘, ‘‘)

    Since I did this, all the widgets have disappeared from my site. If you have a look at, you’ll see there is no left hand column. It appears that the URLs within the posts was updated as intended, as the image file paths have changed (if you inspect the element of any images within posts, they come up as hosted at “….”).

    I have logged into the WordPress admin area of my site and the widget boxes have actually disappeared from the admin area too. They’re not in the inactive or the active widgets list.

    Does anyone know which SQL query might have caused the widgets to disappear, and more importantly, does anyone know how to fix it??

    I don’t know if it matters, but I’m running a child theme of Twenty Twelve which I created myself. I can’t see any other errors at the moment except that I appear to have also taken my self-hosted email address offline with the same SQL queries, but I will worry about that later!

Viewing 3 replies - 1 through 3 (of 3 total)
  • This not a WordPress error, it’s an unfortunate consequence of serializing data in a database. I’ll try to explain it as best I can, but if you’re not interested in the explanation, you’re best bet is probably to recreate them.

    Some plugins, widgets, code etc store arrays of data in a single database table cell as serialized data. A simple example.

    maybe_serialize( array( 'url' => '' ) );

    would be stored in the database as:


    So if you’re following along still, in the serialized string, you have s:3 and s:23. The first s:3 precedes a 3 character string. The second s:23 precedes a 23 character string. Therein lies your issue. When you did your find and replace, your replaced a 23 character string, with a whatever # character string that does not equal 23. That will trigger an error and is most probably responsible for your problem.

    You may want to find and replace the serialized version of your string first, and then go back to do your more general search and replace. Obviously this would be done on the original database.


    ... replace(meta_value, 's:5:"apple"', 's:6:"banana"') ...

    Moderator keesiemeijer



    As Christian1012 poits out it’s probably because of the different number of characters in the domains and how WordPress stores it’s data. Always make a backup first if you query the database directly or if you do major search and replace across a whole database (also if using a plugin).

    Make a backup of your database as it’s now and properly label it so in future you don’t restore to it unless absolutely necessary.

    Restore to a backup made before the queries (if you have one).

    After that you can do a search and replace with this tool that doesn’t corrupt serialized strings or objects:

    Thanks both. It’s my fault, I should have excluded serialised arrays from my queries. I read about them before I ran the queries, and then ignored the advice. Tsk tsk.

    Thanks so much for your advice. I have a backup from before the database was connected to the new domain, so I’ll go back to that and start again!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Widgets disappeared after running an SQL query to update links’ is closed to new replies.