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.
- The topic ‘Random Default Theme for Multi Sites’ is closed to new replies.