October 30, 2014

How to Change Your WordPress Theme Without Losing Your Widgets (or your composure)

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.

Day 27 :: Some days

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.

WP Modder runs on the Genesis Framework

Genesis Framework

Genesis empowers you to quickly and easily build incredible websites with WordPress. Whether you're a novice or advanced developer, Genesis provides the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go. It's that simple - start using Genesis now!

Take advantage of the 6 default layout options, comprehensive SEO settings, rock-solid security, flexible theme options, cool custom widgets, custom design hooks, and a huge selection of child themes ("skins") that make your site look the way you want it to. With automatic theme updates and world-class support included, Genesis is the smart choice for your WordPress website or blog.

It's so damn good, I've redesigned all of my sites using Genesis and can confidently recommended it to you here.

Want an Awesome Host? We Recommend HostGator

HostGator for WordPress

Since its establishment in 2002, HostGator has been a world-leading provider of web hosting service. Although their office is in Houston, Texas, they provide top-notch service to clients and developers from over 200 countries internationally with a staff of over 600 employees. They offer Shared, Reseller, VPS, and Dedicated server packages for both beginners and professionals alike.

Each of their shared Web Hosting plans includes 24/7/365 support, a 99.9% uptime guarantee, and a 45-day money-back guarantee. If you would like to learn more, please visit their company page.

I use HostGator for the majority of my own sites and I continually recommend them to my clients. Learn more about HostGator now!

Get our FREE WP Topics Newsletter

The WP Topics newsletter is delivered twice monthly and it's jam packed with information on our WordPress People interviews, WordPress tutorials, new and useful plugins, themes, marketing techniques, and more.

We Respect Your Privacy.

tutorials delivered by email
* indicates required

About Adam W. Warner

I’m a web development consultant and instructor specializing in the use of WordPress and WordPress Multisite.My development philosophy focuses on solutions, education, empowerment, and support for my clients. I will provide you the tools to achieve your project goals, and I will show you how to use those tools.

Comments

  1. I have another wp blog that I don’t use. It has the same layout as my main one, so whenever I want to change something I test it out on the backup blog first.

  2. rgregory says:

    A switch to Thematic? Why the change? I went the other way from thematic to hybrid. I found Hybrid worked more like I wish Thematic did.

  3. @ rgregory,

    I still love the Hybrid framework, but I was really aching to go to a more minimalist look, and the default Thematic style was close to what I wanted. I am also evaluating it for another project…

    …however, after all I’ve been hearing about Thematic lately, I was a bit surprised at the lack of solid documentation, especially as compared to Hybrid.

    Time will tell if it stays but so far it feels good:)

  4. This really help me out with my WordPress theme. Thank you for this wonderful information and I really appeciated this. In return, I should tell this to my friend.

  5. I have used Hybrid News in my other blog but since I don’t subscribe to become premium member than I don’t know how to tweak the theme to its best performance, so far I just use a standard default performance and feeling good about it because of its cool design. And yes I tried Widget reset and it brought back my widget to its place.

    Software For Downloads last blog post..How-To: Setup iTunes DJ on Your Mac and iPhone

  6. thank you i am always looking for ways to customize my things without changing the least amount of things. Very helpful post

  7. When changing a theme, if you change back will everything be the same as it was or will it be completely lost?

  8. Hi Zac,

    Changing your theme is just like changing your shirt, everything should stay the same. However, like something falling out of your shirt pocket and getting lost, sometimes the same thing happens to widgets. I can’t guarantee that you won’t lose widgets.

    Just follow the advice above and manually backup your widget content into a simple text file and you won’t have anything to worry about.

    p.s. You may want to consider using Amazon affiliate links on your reviews of things Keebler Cookie Crunch Cereal.

  9. Thanks Adam, I’ll be sure to back my widgets up before trying anything!

    And I just signed on with Amazon Affiliates. Thanks for pointing that out to me, I didn’t even know a program existed with Amazon.

    Thanks again for everything, man!
    .-= Zac´s last blog ..[Tech Review] Schwinn 12-Function Bicycle Speedometer =-.

  10. Hey no problem, glad I can help:)

    Be sure to check out this plugin to make adding affiliate links super easy…
    http://wordpress.org/extend/plugins/amazon-reloaded-for-wordpress/

  11. You have some great materials. But, what I don’t understand is your failure to use hyperlinks in both your email (no www-just wpmodder.com) or on your page for a home page. It’s a mystery to me.
    .-= Tom Justin´s last blog ..Is The Pain Worth It? =-.

  12. Hello. I am a newbie with WP. I wanted to know if I try a new theme, then switch back to the previous theme, will everything remain as is?

    • Hi Damon,

      Probably not. The thing to do before you change your theme is to move all your widgets to the “inactive widgets” area just below the area that that holds all the widgets you usually choose from. Think of this area as a holding place for your widgets while you make changes.

      The main reason that widgets can get lost or screwy when changing themes is that sometime themes have different “widgetized areas” than other themes. That is, you can put widgets in different areas in different themes. So if you change themes and it has different areas for you to place widgets, then you’re existing widgets don’t know where to go.

      Just move them all to the inactive widgets area before changing your theme, that should keep things safe.

  13. It’s May 2011 and this functionality is still nowhere to be found. People are still copying and pasting into text files and rooting around database backups.

    Come. On. WordPress.

    • Hi j,

      Thanks for commenting. I’ve been successful in simply moving my Widgets to the Inactive Widgets area on several occasions. However, I still backup manually on larger “Widget heavy” projects.

  14. Maybe nobody ever noticed but when you change a theme, any orphaned widget are moved to the bottom Inactive Widgets section complete with their setting!! All you have to do is identify them and move them back to the appropriate sidebar.

    Don’t know when theis first came into existence but I tink it’s been there a long time.

    • Hi Arnold, thanks for commenting. Yes, that’s true and it’s known (as evidenced in the comments), but it wasn’t always that way.

      Some more good news is that the upcoming 3.3 release of WordPress has a new Widget feature included that will remember your widget locations per theme for up to one week, so now when you change themes with different widgetized areas, then switch back to another theme, your widgets will be back in place in the widgetized areas where they were…instead of being dropped into the Inactive Widgets panel.

      Good news for all!

Speak Your Mind

*