0

I have a custom widget in my theme with the id of "widget_my_box_menu" and I'm trying to add that widget to my theme's main sidebar on theme activation. The main sidebar's id is "home-sidebar-widget"

When I activate the theme, the widget_my_box_menu is added to the "Inactive Widgets" collection instead of the "home-sidebar-widget"

Any ideas what I'm doing wrong?

function my_default_theme_widgets ($old_theme, $WP_theme = null) {
            $new_active_widgets = array (
                'home-sidebar-widget' => array (
                        'widget_my_box_menu',
                ),
        );

        // save new widgets to DB
        update_option('sidebars_widgets', $new_active_widgets);

        //widget title
        update_option( 'widget_my_box_menu', array( 'title' => 'Recent Articles' ));

}
add_action('after_switch_theme', 'my_default_theme_widgets', 10, 2);
  • Have you read this topic? – fuxia Apr 20 '13 at 21:06
  • Yes, but I got a bit lost in the details of the example – N2Mystic Apr 20 '13 at 21:26

Your Answer

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

Browse other questions tagged or ask your own question.