Techniques » Remove Widgets from Twenty Ten WordPress theme

So you want to remove some of the “stock” Widget Areas from the WordPress Twenty Ten theme, how do you go about doing this? We will be using the WordPress function unregister_sidebar(). It is accomplished with a few lines of code in your Twenty Ten child theme’s functions.php file. You are using a child theme, aren’t you?

First define a new function, we used remove_widget_area(). Inside this function we un-register the desired “stock” Widget Areas we don’t want or need. Twenty Ten comes with the following “stock” Widget Areas: primary-widget-area, secondary-widget-area, first-footer-widget-area, second-footer-widget-area, third-footer-widget-area and fourth-footer-widget-area.

1
2
3
4
5
6
7
function remove_widget_area() {
	unregister_sidebar( 'secondary-widget-area' );
	unregister_sidebar( 'first-footer-widget-area' );
	unregister_sidebar( 'second-footer-widget-area' );
	unregister_sidebar( 'third-footer-widget-area' );
	unregister_sidebar( 'fourth-footer-widget-area' );
}

We then initiate the new remove_widget_area() function using the add_action() WordPress function as shown below.

1
add_action( 'admin_init', 'remove_widget_area');

Putting it all together yields the following code to be placed in your theme’s functions.php file:

1
2
3
4
5
6
7
8
9
/* Remove "extra" Twenty Ten Widget Areas *******************************************************/
function remove_widget_area() {
	unregister_sidebar( 'secondary-widget-area' );
	unregister_sidebar( 'first-footer-widget-area' );
	unregister_sidebar( 'second-footer-widget-area' );
	unregister_sidebar( 'third-footer-widget-area' );
	unregister_sidebar( 'fourth-footer-widget-area' );
}
add_action( 'admin_init', 'remove_widget_area');

It’s just that simple, now it’s your turn!

About Corey

Corey was born, raised, and still lives in CMCH, NJ (about 5 minutes outside of Wildwood). He loves the Jersey Shore, and has loads of sand in his shoes! He has been involved with computers and programming since first purchasing a Commodore 64 in 1984. Corey formally began a web design company in 2004, ever broadening his progamming languages and skills since. code

6 Responses to Remove Widgets from Twenty Ten WordPress theme

  1. Thanks for the post.. It is really helpful for me. I wanted to remove the default widgets from the theme and want to try with some new widgets. Can i replace the default widgets?

    • Corey says:

      Sure, adding (registering) new sidebars is just as simple, use either of these WordPress functions register_sidebars() or register_sidebar(), follow the links for the details. The first function registers multiple sidebars, the second registers single sidebars with the addition of allowing for unique names.

  2. Corey, Thanks for your help here. I will try with this. :)

  3. Jim H says:

    Corey, thanks for your post. Instead of deleting a standard widget area from Twenty Ten, I want to move one (“Secondary Widget Area” is its default name in the theme) so it’s directly below the horizontal menu bar on my site’s home page–which would put it in the index.php template, I think?

    Seems like it should be easy to do, but I’ve looked at SOOOO many sites for advice on how to do this, and most of them are confusing me or not exactly addressing this need.

    Can you tell me what to do? Visit the URL I’ve listed, scroll down to the bottom and you’ll see the (widget-driven) slide show that I want to position just below the horizontal nav bar. THANKS!

    • Troy says:

      Jim, try moving the code:

      1
      2
      3
      4
      5
      6
      7
      8
      9
      
      <?php
      	// A second sidebar for widgets, just because.
      	if ( is_active_sidebar( 'secondary-widget-area' ) ) : ?>
      	<div id="secondary" class="widget-area" role="complementary">
      		<ul class="xoxo">
      		<?php dynamic_sidebar( 'secondary-widget-area' ); ?>
      		</ul>
      	</div><!-- #secondary .widget-area -->
      <?php endif; ?>

      …from sidebar.php to either your header.php or index.php.
      Make sure you create a sidebar.php in your child theme (with the above code removed.)

  4. Mizan says:

    Thanks. i need just one widget. i was adding to wrong hook. some of wordpress documentation doesnt provide enough information for new developers.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>