WordPress.org

Ready to get started?Download WordPress

Forums

Saving Widgets by Theme? (6 posts)

  1. ColdPhilter
    Member
    Posted 7 years ago #

    Hello,

    I have a question I hope you can answer. I am currently testing several themes for WordPress on my site (alexlandis.com), and would like to give my visitors to switch themes themselves if they want. I have found the "theme switcher" plugin for this.

    My question comes from the use of widgets. Some of the themes are very different from one another and I don't want them sharing the same widget list. Is it possible to save the widgets you are using on a per theme basis so you don't have to change them each time you change the theme?

    I figure there might be a plugin for this, or an option I can change but I couldn't find either. Thanks for the help in advance!

  2. Ron Pemberton
    Member
    Posted 7 years ago #

    I would also like to know the answer to this.

  3. Root
    Member
    Posted 7 years ago #

    This is a very interesting question with a lot of implications.

  4. ColdPhilter
    Member
    Posted 7 years ago #

    Does anyone know of such a plugin?

  5. barnz2k
    Member
    Posted 7 years ago #

    according to THIS SITE

    The Widgets plugin has the capability of saving widget schemes on a per template basis but that is only if the sidebar names are unique. Otherwise the information will be overwritten by the new sidebar widget scheme if it has the same name

    Ive managed to individually name my sidebars now, and it registers inside the widgets sidebar management - but its still not saving them. So not sure but maybe this is the direction at least??

  6. barnz2k
    Member
    Posted 7 years ago #

    Well this is a pretty hacked up method, but its the only
    thing I have working right now..

    For only 2 themes this isnt so bad..Sorry CP this might be too painful for "several themes"!

    create the same sidebars in BOTH themes and name them something you can remember

    - In functions.php (in each template folder), adjust your register_sidebar code to something like:

    `
    register_sidebar(array('name'=>'Theme 1 bar 1'));
    register_sidebar(array('name'=>'Theme 1 bar 2'));
    register_sidebar(array('name'=>'Theme 2 bar 1'));
    register_sidebar(array('name'=>'Theme 2 bar 2'));`

    Then use MartinStudio's code to call the particular sidebars in each theme's sidebar.php, and to duplicate widgets to use more than once. You dont have to use his statements per page etc if you just want to change per theme - so take out the If satements and just make it whatever you need..

    - ie, for theme 2 sidebar 1 it would be:

    $sidebar_index=3;

    - For duping the widgets just copy his instructions for whatever widget you want more of.

    NOW when you go to the widgets sidebar management you will see all 4 sidebars and be able to put multiple copies of the same widget on any sidebar.

    Then when you switch themes the same sidebars are always shown in manager, but you should only see the 2 related sidebars on the site! :)

    I cant link to mine cause its all Local right now. but it works. and its friday.

Topic Closed

This topic has been closed to new replies.

About this Topic