This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Tagged: ,

Setting Default Widgets for the Right Sidebar

  • Creator
    Topic
  • #19020
    askwpgirl
    Participant

    Hi Jason,

    I’m setting up a WordPress multisite for my son’s old elementary school. Each teacher will have their own subdomain. I want to make it easy for the school staff to set up each subdomain, so I’ve set default theme options, settings, etc.

    What I’d also like to do is assign a couple of the WordPress widgets (Recent Posts, Categories, and Archives) to the right sidebar, so when the subdomain site is set up and the theme is auto activated, those widgets are already in the right sidebar.

    Is there any easy way to do this? It seems like it would be a database setting.

    Thanks! No hurry. I have a little time before we start building the staff sites. I just feel goofy for not being able to find an answer to this anywhere.

    Angela

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #19024
    Jason Bobich
    Keymaster

    Hi Angela,

    This doesn’t really have anything to do with the theme. How widget data is saved in WordPress is a little wonky, but it’s worth learning about to be able to do what you’re looking to do. WordPress stores all the widget data in the general option table of the database.

    Print out the data of what widgets are located in what widget areas.

    $data = get_option('sidebars_widgets');
    print_r($data);

    Then, for each type of widget all of the data is stored in its own option. So, for example, print out all settings for every instance of a text widget.

    $data = get_option('widget_text');
    print_r($data);

    If you want to get all option data and print it all out on the page.

    $data = wp_load_alloptions();
    print_r($data);

    … I can’t write it well here in the forum because the forum processes pre tags, but printing out your data on the screen will be easier to read if you use pre tags.

    echo ‘<pre>’; print_r($data); echo ‘</pre>’;

    #19210
    askwpgirl
    Participant

    Thanks! I wasn’t sure if there were theme functions that set this, but it does sound like a generic WP thing. I’ll study up! It will come in so handy with multi-site setups.

    #19213
    Jason Bobich
    Keymaster

    Yeah, it’s pretty convoluted and weird. The only reason I know about it is because I’ve created a system in the new Jump Start that adds a few option to WordPress’s import to set up your site exactly like the Jump Start demo. But it’s not really fresh in my mind any more.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.