1

I'm developing a custom theme and I added some widgetized sidebars like so:

register_sidebars(2, array('name'=>'Foobar %d'));

I then recreated them so that I could give them semantic names. Like so:

register_sidebar(register_sidebar(
    array(
        'name' => 'Sidebar'
    )
));
register_sidebar(register_sidebar(
    array(
        'name' => 'Sub Menu'
    )
));

But now in my admin area I see 4 sidebars. How do I delete the two older sidebars? I can unregister them using unregister_sidebar but I don't want to keep those 2 lines of code in my theme forever.

I found this in the DB under wp_options under sidebars_widgets. It looks like they are indeed saved in the DB. Do you have any idea which bits to delete?

a:6:{s:19:"wp_inactive_widgets";a:0:{}s:9:"sidebar-1";a:3:{i:0;s:14:"recent-posts-2";i:1;s:10:"archives-2";i:2;s:12:"categories-2";}s:9:"sidebar-2";a:0:{}s:9:"sidebar-3";a:1:{i:0;s:21:"subpages-in-context-2";}s:9:"sidebar-4";a:0:{}s:13:"array_version";i:3;}

Thanks,

  • 2
    Why do you have register_sidebar() inside of register_sidebar() call there?.. – Rarst Aug 23 '12 at 21:09
  • Hint: Use unserialize( $string ); for arrays stored as serialized strings in the DB. – kaiser Aug 23 '12 at 21:49
0

Thanks for the comment @Rarst! That was the issue. For whatever reason I had that extra sidebar method call in there and that was causing the problem.

register_sidebar(
    array(
        'name' => 'Sidebar'
    )
);
register_sidebar(
    array(
        'name' => 'Sub Menu'
    )
);

WordPress saves the data from the widgets in the DB but it doesn't save the widgets themselves - that is controlled entirely by the theme.

Thanks!

-1

I am not sure whether you want to remove sidebar or widget areas, what i think is that you want to remove 2 extra widget areas. All the widget areas are defined in your theme and widget can be defined in plugin also. widget, widget area and sidebar are three different terms so it would be better if you could clarify about what to remove.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.