Support » Networking WordPress » Random Default Theme for Multi Sites

  • I have enabled Multisite and I am the super admin. I have 10 themes in my themes folder and for every new site that gets registered I want to assign a default theme that is randomly selected from those 10 themes automatically. I am trying to achieve this by adding the following code (self-learnt and perhaps, full of mistakes)

    $theme1 =  'surface'; //theme1 folder name
     $theme2 = 'colorway'; //theme2 folder name
     $theme3 = 'amdhas'; //theme3 folder name
     $theme4 = 'swedish-grays'; //theme4 folder name
     $array = array($theme1, $theme2, $theme3, $theme4);
     $random_theme = $array[rand(0, count($array) - 1)];
     define('WP_DEFAULT_THEME', $random_theme);

    I am adding the above code to wp-config.php just before the line “/* That’s all, stop editing! Happy blogging. */”.

    The result is this:

    When a new site is registered, a White Screen comes up and no theme is selected. And when I click on Themes option in Admin panel of that particular site, the following message appears

    The active theme is broken. Reverting to the default theme.

    .. and the very first theme is selected automatically – but it doesnt get a random theme.

    What am I doing wrong here? Can someone please help me in getting this right? In summary, I am looking for help to setup a random default theme when a new site is registered using WordPress Multisite.

    Thanks in Advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Are the random themes available for use on all sites?

    @ipstenu, Yes I’ve made all the random themes available for use on all sites. After I read your reply, I noticed that I did not enable the default Twenty ten. Actually I was right because I did’nt want to include Twenty ten as part of my random theme array. But somehow felt I should enable it. And it did the trick. Once I enabled this particular theme, every new site started getting a random theme from my array on first sign-up. This was good. But I still wonder why I have to enable twenty ten, specially when it was not part of my random array. May be a question to ponder. Thanks for your lead.

    Probably because 2010 is the ‘real’ default (if you have nothing listed, we fall back to that, or 2011) so with it missing, WP freaked.

    Might be worth reading

    and changing the ‘real’ default to one of your random themes.

    It’s as simple as adding

    define('WP_DEFAULT_THEME', 'theme-folder-name');

    to your wp-config 😉

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Random Default Theme for Multi Sites’ is closed to new replies.