Have your widgets ever been stuck in another widget area? Have they ever disappeared when you switched WordPress themes?
Well, this little plugin is for completely resetting your widgets back to the factory settings.
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.
Why create a plugin to reset widgets?
If you’ve hung out around the WordPress.org support forums lately, you’ve probably seen a few people wondering why their widgets disappeared when changing themes. I also had this same issue on one of the releases of the Hybrid theme.
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.
Download the Widgets Reset WordPress plugin
Note: If you have important information saved in something like a text widget, you better find a way to save it before resetting your widgets because you’ll lose that information. In short, don’t complain if you lose widget information that you decided to reset.
See the readme.html file in the plugin download for full instructions.
How to manually reset your widgets
Actually, this plugin just provides a pretty interface. You really don’t need the plugin. A simple way to do this would be to drop the below code in your theme’s functions.php file and hit refresh on your browser.
<?php update_option( 'sidebars_widgets', $null ); ?>
Then, just remove it. But, if the thought of adding PHP code scares you, just use the plugin.
I recently encountered this problem, but remembered where it was hiding.
I think I plugin’s an awkward solution to this problem; the core of WordPress should feature this functionality in some way. Either with a prompt before you change themes (if you were using widgets and it had more than the standard) or with a way to reset them. Perhaps a combination of the two is the best solution.
I’m also thinking that perhaps widget makers should always allow more than one widget to exist. I can’t think of a good reason that you wouldn’t want to allow multiple instances of it. (Having said that, I’m not 100% sure how to do it. I need to look into that.)
david (b) — A plugin is definitely an awkward solution, but just in case a little PHP scares some users, I made it easy. Now, there truly is a plugin for everything.
A widgets reset button wouldn’t hurt. But, what many are seeing as a problem is actually a feature — custom widget area IDs. I just can’t think of how WordPress is supposed to know if a new theme is using different IDs and prompt the user.
I definitely agree that all widgets should be multi-widgets. I don’t see much point in single-use widgets. This issue generally crops up when users can’t add a single-use widget again.
I’ve heard the the widget admin is getting an overhaul in 2.8, so I’m hoping some of the issues we’ve seen, including this one, are addressed in some way.
Justin (No comment threading, huh? (Though I don’t think I have it running on any public site either…)) — Your point that it’s something of a feature is sound, but it’s a problematic one. The issue is that there are two basic usage cases: those who want a sidebar with the same stuff regardless of the theme they decide to use today and those who want to use a sidebar to customize the workings of a specific theme.
The solution that works well for the first case–to always keep all widgets intact when switching themes–fails in the second. The better solution for the second case is to have WordPress remember what widgets are where on a per theme basis, but release them when an individual case is not being used.
The more I think about it, though, the more I think the current solution could be the best. It’s very likely that the first case I mention is more common than the second. And that few themes have more than one widgetable area. And that average users rarely change their theme or widgets after they’ve found a configuration they like.
Figuring this one out saved my butt on a client project.
http://comox.textdrive.com/pipermail/wp-hackers/2008-December/023354.html
david (b) — I’m giving comment threading a go on another site. I’m just not sure it’s for me. I start getting lost when there are too many threads running.
I’d definitely like to see some solutions from the WP.org folks. The first case is probably more prevalent.
Another issue is that themes might have identical widget area IDs and widgets go in an odd area, which is common because many theme developers don’t add in an
idargument forregister_sidebar(). For example, you might have something like widgets from the sidebar in one theme go to the header in another.I like several things about the current widget system, but there there are some major issues that need to be addressed.
Nathan Rice — It saved my butt from 100s of angry Hybrid theme users when I added in widget area IDs.
I think if I were building the widget system I probably would have automatically unregistered any widgets that were attached to sidebars that didn’t exist.
There are other options, for example, registering any sidebars that the theme didn’t register but had widgets applied to them so the widgets could be removed; that would be fairly simple to do as a plugin, or even better having my preferred option but with a way to save widget settings as an xml file so the settings could be reloaded, or even for a default set to be available as part of a theme,
Andrew — I’d like to see themes be able to easily set widgets when first uploaded. I’m thinking this has to be possible, but I haven’t really toyed around with the idea.
I used to always wonder where my widgets went after switching themes. After peeking around the options db, I saw the “sidebars_widgets” field. So I pretty much did what NR posted the manual way
I also tweeted about presetting widgets once a theme is activated. Plan on hacking on that pretty soon.
Ptah Dunbar — Yeah, I remember seeing that tweet now. Presetting widgets is something I’ve been wanting to do with Hybrid because its widget areas completely collapse when no widgets are set. This makes my theme look bad on the WP.org theme preview.
If you figure it out before I do, you need to write up a blog post on it.
hi. Thanks for plugin
perfect.
Regards
I had lost lot of widgets while changing themes … now this plugin saved me
thanks a lot ..
Ma frend… Great Job… is there any compilations of the plugins you made?
Justin,
Great plugin! It saved my life. I lost half my widgets when I updated my theme a couple days ago and it was driving me nuts!
Your plugin is awesome! It did the trick. I think it’s one of the most fabulous plugins I’ve ever used.
Thanks a lot.
~ Annie
Holy cow Justin, your timing couldn’t have been better. I learned of this problem when you first wrote about it a couple weeks ago. I didn’t have a need for the plugin but I did tuck the information away in the back of my brain. Then, today, all of the sudden half my widgets stopped working, on five sites, after migrating to a new domain and new server. I knew immediately what the problem was and used your plugin to set things straight.
Thanks very much for bringing attention to this problem and providing the simple fix.
Cheers
Hey buddy! I want to say my lodz of thanksssss
This widgets shit made me so much tensed:(
and u blog came like an angel.
thanks alot
Allah Bless YOU
Another incredibly satisfied user. I will tweet when I get the chance to properly sing its praises…
James
I’m a little confused about why you would need a plugin for this. There is a REALLY simple fix that works for this problem:
This specifically deals with the problems of disappearing widgets after theme changes.
baron — You’re welcome.
dinu — Well, I’m glad I could save you a little frustration.
keep informed — Yeah, just check out my plugins archive for more.
Annie Anderson — I don’t know if I’d call it “fabulous,” but I’ll take the compliments either way.
Chris Hajer — No problem. It’s really just a Band-Aid for a much larger issue with WordPress widgets. I’m hoping by WP 2.9, some of these things are addressed with an upgrade to the widgets panel.
Naqqash M Khan — I’m glad I could help.
James — Feel free to tweet about it. Thanks for stopping by from the forums.
Katie Brooks — I’m guessing you’ve never had to switch out widgets from a theme with 10+ widget areas before. Or, needed to remove widget areas from four or five different themes on one install before. Doing it through the widgets panel is a pain.
The page you linked to is actually harder to do than the one line of code I posted above. It’s not a “REALLY simple fix.” It’s a pain in the ass because someone’s got to remove 30 different widgets out of 10 different widget areas.
I’m going to remove the link to that page because I believe it is not beneficial to my readers when an actual simple fix (one that takes a few seconds of time) is posted above.
Thanks for the plugin; it solved my case of disappearing widgets after moving one host to another.
Thanks, Justin! This post and solutions are a lifesaver.
Used your theme, but came up with error. Now I have a space with all sorts of nonsense text showing up at the top of my blog: systemsofsupport.org/udlblog. Please advise.
Sorry, that should have read that I used your plugin (widget reset)…
I apologize for all of the posts. Just in case someone else has this problem. I ended up having to delete entire directory from blog. Luckily my host makes a daily backup so I was able to restore site from it.
Gavan Watson — You’re welcome. Luckily, in WordPress 2.8, disappearing widgets won’t be such a pain.
grateful — I’m glad I could be of help.
Jason — It sounds like your issues go well beyond the scope of this plugin.
This widget is great, it installs easy to reset my widgets, however it didn’t fix the widgets that “disappeared” as they were moved around in the wp admin section yet continue to appear on the site. I’ve tried to remove them through phpmyadmin to no avail. Any suggestions?
Thanks for this – found this post on google. I did it the manual way and it took just a few secs and I was back in business. I heard of another plugin called widget slayer (?) but after the fact.
Cheers.
Hi
I have a similar problem with widgets when I switched to a new theme, then switched back, so thought I’d try the above line of code. I’m using WP 2.7.1, Magazine Basic 2.4.2, 1024wide, 2 sidebars. The problem is the selected widgets (search, tags, categoires, calander and archieves) on the right-hand sidebar are also duplicated (ghosted) on the left-sidebar too. The left-sidebar has recent comments and text widgets selected. The duplication of the right-sidebar widgets positions itself below the left sidebar. So I thought I’d use the code above just to clear them all out. These ghost widgets displayed on the main blog page (not on a post page).
In Dashboard-Appearance-Widgets the ghost widges are listed as unavailable but are not in the list on the right of selected widgets, so therefore they can not be removed. The effect of using the above line cleared only the left-sidebar widgets that had been selected. The previously selected right-sidebar and its ghost duplicate positioned on the lower left were not cleared, but remained. I placed the line of code at the very top of functions.php. Any advice on solutions I might try to resolve this problem would be appreciated. I’m a newbie and this is driving me mad, well a little bit! Thanks.
Thanks for the tip Justin! – Have been testing custom widgets in templates and quickly managed to assign widgets to sidebars we had removed. Adding the line into function.php works like a charm.
You just saved me from an hour of code hunting. Thanks!
Thanks, I’d spent far to long trying to sort this out, your one line of code fixed it for me. Many thanks
My widgets did just all disappear in 2.8 and I am using the same theme as before. The reset widget does not seem compatible with 2.8.
I restored my settings and deactivated my widget cache and hope it does not happen again, as it happened last time when i cleared the widget cache.
Bill
This plugin is super helpful. NOTE: The WordPress Plugin … area … place where you get them says, “Compatible up to: 2.7.1″ and gives a warning. That will put some folk off using it. In truth, it worked great on my 2.8.
Perhaps you can get WordPress to update their message Justin.
It sure is a life-saver as WP 2.8 stored a bunch of Widgets I had experimented with but didn’t realize were saved somewhere. Those experiments caused actual widgets not to work until I downloaded this.
justin i have desperate need of this idea and got if from here , i want to thank for make this as a plugin and very handy for everyone.
I attempted to upload your Widgets Reset php file and here is what i got!
YIKES! What can I do now? Thanks, Justin.
Terry V
I upgraded to wordpress 2.84 with Magazine Basic theme and the Tags widget has disappeared from the list of available widgets and inactive widgets. I’ve used your widgets reset, it removes the widgets from Sidebar 1 and Sidebar 2 on the widgets page, but 4 of the widgets show on the site sidebar, including the tags list. On another website when I upgraded, I used your widgets reset plugin and it solved my problem. Does your widgets reset work with wordpress version 2.84? Is there something else I can try to resolve this?
Having no luck with the plugin getting my tag_cloud widget back, I found a forum topic at wordpress.org helpful in resolving this. Here’s what I did. Perhaps you can make the widget accomplish this so that others do not have this problem.
I went into the database and restored the widget_tag_cloud row from a database backup.Changed option_value
from a:2:{s:5:”title”;s:6:”Topics”;s:12:”_multiwidget”;i:1;}
to a:3:{i:2;a:0:{}i:3;a:1:{s:5:”title”;s:6:”Topics”;}s:12:”_multiwidget”;i:1;}
The tag cloud widget reappeared in the widgets screen and I was able to add it back to the sidebar. Resolved for now.
Follow flora’s clue, I checked the value of the widget options in a fresh Wordpress install, and found they were all the same:
a:2:{i:2;a:0:{}s:12:”_multiwidget”;i:1;}
I updated all mine to match, and the missing Widgets came back.
+1 to add a SQL update to Widget Reset plugin.
Great plugin, will use this for my new blog.
Thank you
Hi Justin
Just installed your Reset plugin and it looks and works beautifully. It was just what I needed to implement contextual sidebars. Thanks for your work.
Odd problem though: I uploaded via ftp instead of WP Admin, and the plugin activated itself without showing up at all in the Plugins Panel. I deleted it from my server via ftp, expecting it to disappear so that I could upload via WP and hopefully have it appear properly in the Plugins Panel.
But…it is still installed after being deleted from my server. I love the plugin, but have no control over it status now.
Any suggestions?
Cheers
Ignore last post…for starters I meant Widgets Reloaded, not Reset. And I solved the problem myself anyway.
Thanks again for the great plugin!
Hi folks,
Thanks for this plugin.
Should I use it with WP 2.8.6 (and with WP 2.9)?
Thanks,
chris
I get an error on my sidebar when I run the Widget reset:
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /home/content/o/a/r/oaramblinknigh/html/wp-includes/widgets.php on line 852
Instead of clearing out the widgets, the error appears and the widgets remain.
Any ideas?
Was there ever a fix found for Ryan’s problem?
My Tag Cloud widget along with a few others has disappeared some time ago and I can’t seem to get them back (hardcoded the tag cloud at the moment).
Widget Reset is not helping at all – doesn’t seem to be doing anything.
I’m at the latest 2.8.
Any ideas? Help please!
Thanks for the great plugin! I think it’s really cool you explain that the plugin isn’t needed and provide the code to do it manually. Good deal!
Thanks for this plugin, it’s great.
I don’t mean to disrupt the conversation here, but Do you have any idea why there are Blank Spaces inside my Widgets Panel? Somehow I can’t get a fix for that. Email is inside. Thanks
Hello
i think a security token is missing here, so a XSRF vulnerability is present.
Not a big deal, it will just erase the widget from sidebar, pretty anoying …
See you
Julio
You just saved my ass! Hours of work. Thanks so much!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Hi,
Im trying to hide, not to remove, the “Inactive widgets” metabox on “appearance->widgets” menu using functions.php… so nobody can see this metabox.
But after many many hours searching on the web I doesnt found how
Any help?
Regards,
George
Hi,
I inserted the coding in the functions.php file and now I just get a blank page saying this
Parse error: syntax error, unexpected ‘<' in /home/dearnevi/public_html/wp-content/themes/oxygen/admin/functions-admin.php on line 213
everytime I try to do anything, can you help please?
Many Thanks