If you’re a regular reader of WPM, you may have noticed that I’ve changed the look and feel of the site recently. While changing themes, I ran into a Widgets issue that I had forgotten about. Sometimes when changing themes, the new theme you’ve chosen won’t display your Widgets properly. This is kind of a big deal, especially for those WordPress users who are unaware and complete a theme change, only to discover their Widgets are gone.
Now this isn’t such a big deal for standard WordPress Widgets like Pages, Categories, and Archives, but like many of you, I have created several Text Widgets that contain hand-written code, custom scripts, and forms. I also use the Query Posts Widget which contains hand-entered parameters. So, how do we avoid disaster?
Why Does This Happen?
An explanation from Justin Tadlock:
Basically, widget areas (aka sidebars) with unique IDs will throw things off. Widgets are added according to a widget area’s ID. When you change themes that have different IDs, the widgets are no longer where you might expect them to be.
How to Avoid Trouble?
Before changing your theme, do the following:
1. Get the right tool for the job.
The first thing you’ll want to do is download the Widgets Reset plugin, again, from Justin Tadlock. This plugin will allow to you completely reset your WordPress Widgets to the default WordPress settings. Notice the emphasis and beware from the plugin’s site:
It’s not for moving widgets, saving widgets, or anything of the sort. When I say it resets your widgets, I really mean it. The slate is wiped completely clean.
Install and activate this plugin, but DO NOT USE IT YET.
2. Backup your Widgets.
Unfortunately, neither the plugin above, nor any other automated method I’m aware of allows you to backup your Widgets. You’re going to have to go “old school” and do it manually. In your WordPress backend, go to the Widgets settings and start copying and pasting the code from each of your Widgets into a simple text document. I had over a dozen Widgets, and most had the Widget Logic plugin applied, so it took some time.
Now Breathe Easy, Almost.
Now that your certain your Widgets are all backed up properly, go into the Appearance tab and change your theme. With any luck, your Widgets (or some of them) will be preserved, but most likely you will have lost some, if not all. At this stage, you may also notice that when you go into the Widgets area, there will be some Widgets listed, but they will be missing the “Add” button. Weird huh? Those Widgets are now in “Limbo”. The good news is that hopefully you’ve installed the Widgets Reset plugin. If so, simply navigate to “Widgets Reset” under the Appearance tab and reset the Widgets. You should now see all your Widgets available with an “Add” button.
Put the Pieces Back Together.
Now for the manual labor. You’ll need to recreate each Widget you had previously by using the code you’ve copied into your backup text file. Don’t worry, it goes pretty fast. I had recreated most of the Widgets I had within about 10 minutes.
Also, it was a great time for me to review the Widgets I had and give a couple of them the boot.