WordPress.org

Ready to get started?Download WordPress

Forums

How to change the default theme to existing sites on Multisite? (12 posts)

  1. tomystein
    Member
    Posted 1 year ago #

    Hi,

    I've read a lot about this issue and tried many things but can't get the result I want - to change the default twentyeleven theme.

    I've put this line in wp-config, with the theme folder I want:
    define('WP_DEFAULT_THEME', 'classic');
    I get a blank page.

    Tried also to change the names of the themes in their stylesheets, their folder names. To change the default theme in default-constants.php. Nothing works.

    I am working with subdomains if that's important to mention.
    I have a network of 50 sites and want to change all themes at once.

    Advice will be appreciated! :)
    Thanks...

  2. tomystein
    Member
    Posted 1 year ago #

    I thought maybe using a kind of this command:

    SELECT * FROM wp_options WHERE option_name = 'template' OR option_name = 'stylesheet' OR option_name = 'current_theme';

    But I don't know how to select all wp_options (wp_2_options, etc...).

    Thanks.

  3. tomystein
    Member
    Posted 1 year ago #

    Does anybody have any experince with this? Is it the proper place to ask or is there a multisite forum for questions like this?

  4. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    Yes, there is a multisite forum - it's listed on this page:
    http://wordpress.org/support/

    I will move this thread there for you :).

  5. tomystein
    Member
    Posted 1 year ago #

    Thanks a lot.

  6. For existing sites you have to edit them manually or via the DB.

    And you can't select multiple tables on a search easily in SQL (for a variety of 'don't shoot yourself in the foot' reasons). You'd have to script something via PHP or shell.

    Honestly, I'd do something like this:

    UPDATE wp_options SET template = 'current_theme', stylesheet = 'current_theme';
    UPDATE wp_2_options SET template = 'current_theme', stylesheet = 'current_theme';

    And make all fifty. Then paste it into phpMyAdmin and it'll run 'em all.

    Read http://www.techonthenet.com/sql/update.php and practice on a safe local DB first! Also? BACKUP FIRST! :D

  7. tomystein
    Member
    Posted 1 year ago #

    I think I will use Excel to create all the wp_options and then use the command you recommended, which I was thinking about as well :)

    Thanks.

  8. tomystein
    Member
    Posted 1 year ago #

    Do I need to update current_theme as well?

    You mentioned template and stylesheet only.

  9. tomystein
    Member
    Posted 1 year ago #

    When I try this,

    UPDATE wp_3_options SET template = 'templatedir';

    It gives me an error:
    #1054 - Unknown column 'template' in 'field list'

  10. tomystein
    Member
    Posted 1 year ago #

    this worked for me.

    UPDATE wp_options SET option_value='test' WHERE option_name='template' OR option_name='stylesheet';

  11. David Sader
    Member
    Posted 1 year ago #

    I'll offer a couple snippets from my "mu-plugins".

    First, as a temporary network-wide override of each site's theme WITHOUT altering the site-by-site theme options.

    <?php
    add_filter( 'pre_option_' . 'template', 'override_template' );
    add_filter( 'pre_option_' . 'stylesheet', 'override_stylesheet' );
    
    function my_override_template() {
    	$foo = 'twentytwelve';
    	return $foo;
    }
    function my_override_stylesheet() {
    	$bar = 'twentytwelve';
    	return $bar;
    }
    ?>

    Second, to actually change each site's theme options I'd hook the Update Network button with this snippet in "mu-plugins":

    <?php
    function my_theme( $blog_id ) {
    update_blog_option( $blog_id, 'template', 'twentytwelve' );
    update_blog_option( $blog_id, 'stylesheet', 'twentytwelve' );
    }
    add_action( 'wpmu_upgrade_site', 'my_theme' );
    ?>
  12. Oh that is SLICK David! :D

Topic Closed

This topic has been closed to new replies.

About this Topic