Support » Themes and Templates » How To Force Themes To Keep Sidebar Contents

  • I’m trying to build a site which will allow users to switch between two totally different themes.

    Theme 1 happens to have a left & right sidebar with menu widgets, etc. spread between ’em.
    Theme 2 happens to have one sidebar with all the widgets condensed to that one sidebar.

    I’ve got them both designed and sorted out, but each time I switch from Theme 1 to Theme 2 (or vice versa), the sidebars reset to default widgets – and my customs go into inactive, which I realize is what’s supposed to happen… but…

    Is there a way to force the theme to keep the contents of the sidebar(s) so when I switch back and forth, they retain the same widget positioning (which in turn will allow users to switch the theme and still see everything).

Viewing 4 replies - 1 through 4 (of 4 total)
  • Chip Bennett


    Theme Review Admin

    In your register_sidebar() calls in both Themes, ensure that you give the same sidebars the same names (slugs) and IDs. I’m not completely sure that it will work, but it… might?

    I see what you’re saying but I don’t think that will work. I also didn’t make myself clear…
    One wrench in the system is that Theme 2 has some extra widgets in it.

    So, even if I were to name them the same, they still need to retain their respective widgets, which differ from each other.

    Chip Bennett


    Theme Review Admin

    Well then that’s impossible. Theme A has no way of knowing about the custom Widgets in Theme B.

    You need to make all Widgets available to both Themes, either by registering all appropriate Widgets in both Themes’ functions.php files, or else (perhaps a better solution) package the custom Widgets as a Plugin, so that they’re not Theme-dependent.

    This seems like an unfortunate drawback to WordPress (not that other CMS’s can do it, because I’m not aware of if they can or not). It seems like setting up a theme and savingĀ it should retain all its settings, including what widgets are being used and where.

    Even if I knew how to package them as a plugin, it would make things much more difficult for my client – plus, I’m not sure if saving them as a plugin would keep everything in their same positions upon switching off the theme.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How To Force Themes To Keep Sidebar Contents’ is closed to new replies.