WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The question is regarding, calling the default widgets into the sidebar[s]:

So, despite the solution given in THIS THREAD, I tried a different way - Ian Stewart's borrowed solution given HERE.

It's like, declaring the following lines into functions.php, suppose I have two different sidebars in my theme:

// Preset Widgets
$preset_widgets = array (
        'primary_widget_area'  => array( 'search', 'pages', 'categories', 'archives' ),
        'secondary_widget_area'  => array( 'links', 'meta' )

if ( isset( $_GET['activated'] ) ) {
        update_option( 'sidebars_widgets', $preset_widgets );

//update_option( 'sidebars_widgets', NULL );

// Check for static widgets in widget-ready areas
function is_sidebar_active( $index ){

  global $wp_registered_sidebars;

  $widgetcolums = wp_get_sidebars_widgets();

  if ($widgetcolums[$index]) return true;

        return false;

} // end is_sidebar_active

The problem is, my theme is NOT calling the default widgets in absence of any widgets at the beginning. I can't fix it, because I can't understand the code above and obviously the process explained by Ian Stewart.

And also, can't understand the explanation regarding //update_option( 'sidebars_widgets', NULL );.

How can I fix this?

share|improve this question
You solution may be here – Ravinder Kumar May 23 '13 at 20:07
Thanks @Ravs. It is't showing any fatal error when I've changed is_sidebar_active() into is_active_sidebar() in my sidebar.php. But switching from Twenty Twelve to my theme it's not showing the defaults widgets. I emptied the widget areas first in my theme, and then tried. Any other option? – Mayeenul Islam May 24 '13 at 2:48
I even used 'Theme Test Drive' plugin to see the default widget mode, it's not showing the defaults. :( – Mayeenul Islam May 24 '13 at 2:57
up vote 0 down vote accepted

I solved the issue using a fallback with PHP conditionals: in my sidebar.php I coded like the following:

<?php if( is_active_sidebar('my_sidebar') ) { ?>

        <div id="secondary" class="widget-area">
            <ul class="xoxo">
                <?php dynamic_sidebar('my_sidebar'); ?>
        </div><!-- #secondary .widget-area -->

<?php } else { ?>

        <div id="secondary" class="widget-area">
            <ul class="xoxo">

                <?php // Default Widget : Archives ?>
                <li id="default-widget-1" class="widget-container default-widgets">
                    <h3 class="widget-title"><?php _e( 'Archives', 'your-theme' ); ?></h3>
                        <?php wp_get_archives( array( 'type' => 'monthly' ) ); ?>
                </li> <!-- #default-widget-1 -->

                <?php // Default Widget : Pages ?>
                <li id="default-widget-2" class="widget-container default-widgets">
                    <h3 class="widget-title"><?php _e( 'Pages', 'your-theme' ); ?></h3>
                        <?php wp_list_pages('sort_column=menu_order&title_li='); ?>
                </li> <!-- #default-widget-2 -->

                <?php // Default Widget : Categories ?>
                <li id="default-widget-3" class="widget-container default-widgets">
                    <h3 class="widget-title"><?php _e( 'Categories', 'your-theme' ); ?></h3>                            
                        <?php wp_list_categories( 'sort_column=menu_order&title_li=' ); ?>
                </li> <!-- #default-widget-3 -->

                <?php // Default Widget : Meta ?>
                <li id="default-widget-4" class="widget-container default-widgets">
                    <h3 class="widget-title"><?php _e( 'Meta', 'your-theme' ); ?></h3>                            
                        <?php wp_register(); ?>
                        <li><?php wp_loginout(); ?></li>
                        <?php wp_meta(); ?>
                </li> <!-- #default-widget-4 -->

            </ul> <!-- .xoxo -->

        </div><!-- #secondary .widget-area -->

<?php } //endif( is_active_sidebar ?>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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