• Hello everyone,

    I have multisite feature installed in my WP3 installation and we have our custom theme set as default for all the subsites. The problem is that when a new subsite is created, the sidebar is totally empty as not showing any widgets (eventhough there are widgets put via the Dashboard). But once you put an any new widget in the list and go back to the blog page, suddently they all appear there. Is this a common issue and does someone has a solution? Would be nice to get the content in sidebar appear at once that any extra work would be avoided 🙂

    Another question is that is it possible to set default widgets for new subsites? (At the moment there are some widgets I don’t want to be in new sites and they need to be removed manually which is again extra work)

    Great thanks for you help in advance!

Viewing 6 replies - 1 through 6 (of 6 total)
  • No, there isn’t an easy way to set default widgets.

    you could put the non-widget code for sidebar items in the theme’s sidebar.php file.

    Each blog is independent. It doesn’t matter what you do with the widget on one blog, it will not affect the other ones.

    Thread Starter quinz

    (@quinz)

    Hi Andrea and many thanks to your reply,

    this really solves one of the problems (I guess I just deactivate the widgets I don’t want to be in there and write the important widgets permanently into the sidebar.php)

    There is still this first issue remaining. Unfortunately I’m not sure if you got the problem right. I don’t want to change widgets for all subsites at once 🙂 The thing is that they are somehow hidden in the beginning when a new site is been created, eventhough there are several widgets as default in the Primary Widget Area. But if I add for example the calendar widget into the primary widgets and then visit my sub blog, all the default widgets and the calendar appears. So what I’d like to know, is there a way to get those default widgets appear without adding and removing one widget everytime I create a subsite? 🙂

    that;s default widget behavior. the items you see initially are hardcoded into the theme’s sidebar. they are NOT widgets. 🙂

    So, that’s why you have to visit the backend and drag what you want. As soon as you drag a widget into an empty widgetized area, it hides the code that was previously there.

    I’m suggesting take that sidebar.php file, rearrange and add the code you want, and forgot the widget part.

    Once you have a look at the code in that file, it all becomes clearer.

    Thread Starter quinz

    (@quinz)

    Ok thanks 🙂 I appreciate your help.

    You can set default widgets for multisite but you have to edit wp_install_defaults functions in wp-admin/includes/upgrade.php.

    There you can replace update_option( ‘sidebars_widgets’….. row with something like this:

    update_option( 'sidebars_widgets', array ( 'wp_inactive_widgets' => array ( ), 'primary-widget-area' => array ( 0 => 'widget-id-base-2', 1 => 'widget2-id-base-2', 2 => 'widget3-id-base-2', 3 => 'widget4-id-base-2', 4 => 'widget5-id-base-2', ), 'secondary-widget-area' => array ( ), 'first-footer-widget-area' => array ( ), 'second-footer-widget-area' => array ( ), 'third-footer-widget-area' => array ( ), 'fourth-footer-widget-area' => array ( ), 'array_version' => 3 ) );

    The entire function wp_install_defaults {...} from wp-admin/includes/upgrade.php is pluggable(because it is wrapped in if ( !function_exists('wp_install_defaults') ) :). It can be copied and pasted into a new file in the “mu-plugins” folder and will execute instead of the core function.

    Tinker with any defaults listed in your new customized install_defaults mu-plugin.

    Advantage: no core file edits. When upgrading, the contents of the “mu-plugins” folder won’t vanish.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘A widget issue’ is closed to new replies.