Wordpress Widgets Admin Page

With the new WordPress v2.8, the WP-Admin > Appearance > Widgets page presents a new problem for themes with large number of widgetized sidebars, e.g onenews theme in alltop mode, where the number of sidebars can go to the 100s depending on how many pages are created. With around 15 sidebars, it can be a pain when you have to do a lot of scrolling up and down to drag-n-drop the widgets.

We will be re-using the code from WP v2.7 to re-instate the dropdown menu, so that you can choose which sidebar you want to work on. Then we will hide the rest of the unwanted sidebars from view with CSS. As this involves editing the core file widgets.php, we need to duplicate it so that it won’t be overwritten when we do a WordPress upgrade.

So first make a copy of widgets.php in the WP-Admin directory and rename it as widgets-2.php. Open widgets-2.php and look for the following line

<div id="widgets-right">

Insert the following code below it to display the dropdown menu

<?php if (!isset($_GET['sidebar'])) $_GET['sidebar'] = 'sidebar-1'; ?>
<form id="widgets-filter" action="" method="get">
<select id="sidebar-selector" name="sidebar">
<?php foreach ( $wp_registered_sidebars as $sidebar_id => $registered_sidebar ) : $sidebar_id = attribute_escape( $sidebar_id );
if ( 'wp_inactive_widgets' == $sidebar_id )
<option value='<?php echo $sidebar_id; ?>'<?php selected( $sidebar_id, $_GET['sidebar'] ); ?>><?php echo wp_specialchars( $registered_sidebar['name'] ); ?></option>
<?php endforeach; ?>
<input type="submit" value="<?php _e('Show' ); ?>" class="button-secondary" />

Now to hide the rest of the sidebars, replace

For WordPress 3.0-3.2

<div class="widgets-holder-wrap<?php echo $closed; ?>">


<div class="widgets-holder-wrap"<?php if ($_GET['sidebar'] != $registered_sidebar['id']) { echo ' style="display:none"'; } ?>>

For WordPress 3.3

<div class="<?php esc_attr_e( $wrap_class ); ?>">


<div class="<?php esc_attr_e( $wrap_class ); ?>"<?php if ($_GET['sidebar'] != $registered_sidebar['id']) { echo ' style="display:none"'; } ?>>

For WordPress 3.3.1-3.3.2

if ( $i )
$wrap_class .= ' closed'; ?>

<div class="<?php echo esc_attr( $wrap_class ); ?>">


if ( $i )
$wrap_class .= ' closed'; ?>

<div class="<?php esc_attr_e( $wrap_class ); ?>"<?php if ($_GET['sidebar'] != $registered_sidebar['id']) { echo ' style="display:none"'; } ?>>

You can now navigate to http://your-own-domain.com/wp-admin/widgets-2.php to see the hacked widgets page.

Browse and Share

» Subscribe to Feed
» Leave a Comment

Related Posts:
» WP Plugin: Genki Pre-Publish Reminder
» WP Theme: OneNews – Popurls/Alltop Clone
» WP Theme: Woogle The Google Search Engine Clone

» Newer Post:
« Previous Post: