1

I know there is an option to have the following code in the wp-config.php file:

define('WP_DEFAULT_THEME', 'x-child-integrity-light');
define( 'TEMPLATEPATH', 'wp-content/themes/x');

I currently have this commented out and I'm trying to use the WP Replicator to replicate sites in a multisite install. I'd like to have the code automatically activate the child theme when it's installing the new site. By default, it's making the Twenty Fifteen theme active. How can I go about doing this?

2 Answers 2

2

Use switch_theme as already indicated in another answer, but hook it to wpmu_new_blog

This function runs when a user self-registers a new site as well as when a super admin creates a new site. hook to 'wpmu_new_blog' for events that should affect all new sites.

https://codex.wordpress.org/function_reference/wpmu_create_blog

If not the code will run constantly, which will be inefficient and make switching themes impossible ( or unpredictable ).

In other words:

function default_theme_wpse_193024() {
  switch_theme('twentythirteen');
}
add_action('wpmu_new_blog','default_theme_wpse_193024');

For switch_theme(), despite the parameter being named somewhat inexplicably "stylesheet", use the name of the theme folder. Per the Codex:

Accepts one argument: $stylesheet of the theme. ($stylesheet is the name of your folder slug. It's the same value that you'd use for a child theme, something like twentythirteen.)

0
1

You can use the switch_theme function

<?php switch_theme( $stylesheet ) ?>

$stylesheet is the Stylesheet name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.