How to hide a widget in WordPress

You ever want to remove a widget from your sidebar but not lose all the data, settings or text… should be able to save your widget data somehow right?

The solution was, to register another sidebar called “sandbox”. Now I can drag my widgets that I may show once in a while into the “sandbox” holder. Since sandbox is not called from anywhere on the site, I keep all my widget data and simply drag the widget back into place when I need it again.

Here is how I did it…

I use StudioPress for themes but you should be able to do this on any WordPress theme.

Find the functions.php file in your theme folder and enter the following code.

The code for StudioPress:

genesis_register_sidebar( array(
    'id'    => 'generate-sandbox',
    'name'    => __( 'Sandbox', 'generate' ),
    'description'    => __( 'This is the sandbox section.', 'generate' ),
) );

The code for most WordPress themes:

register_sidebar( array(
    'name' => __( 'Sandbox', 'twentyeleven' ),
    'id' => 'sandbox',
    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    'after_widget' => "</aside>",
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
) );

Now you have a widget area called “Sandbox” that you can store re-usable widgets.

Drag the widgets that you want to remove from your site but keep for later use into the “Sandbox” container.

Since anything placed in “Sandbox” is never shown on your site, the Widget sits in a holding area of sorts. Widget data is not lost and you can sleep better at night.

Simple and clean… That’s how I like it…

Hope this helped you out.

Join My Newsletter

Receive tips on business, iOS Development and WordPress.
Learn more about me and my experiences online.

Speak Your Mind