Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter beatR

    (@codepage)

    I didn’t write it correctly in the post. and the link you send is not site/multisite specific.

    I need to ENABLE a theme, that is not network-wide activated, on a specific site(id).

    Means: the available themes are not being activated network-wide. each subsite gets a specific theme enabled, and then activated as current theme.

    activate as current theme i know how to do (via database)

    i dont know how to enable the theme on the site

    Hi, this should do it:

    
    $blog_id = 3; // id of the blog to enable the theme for
    $theme = 'twentyseventeen'; // the theme stylesheet
    $allowed_themes = get_blog_option( $blog_id, 'allowedthemes' );
    if ( !$allowed_themes ) {
        $allowed_themes = array( $theme => true );
    } else {
        $allowed_themes[$theme] = true;
    }
    update_blog_option( $blog_id, 'allowedthemes', $allowed_themes ); 
    
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Enable a theme in PHP’ is closed to new replies.