EuQu
EuQu

Reputation: 21

Wordpress theme depends on domain

How to show different themes on wordpress site depending on site domain? All content the same on all domains/themes.
Is it possible? If so, can you recommend the solution?

Example:
1. site1.com - theme1.
2. site2.com - theme2.
3. same content.

Upvotes: 0

Views: 526

Answers (1)

Kevin Vess
Kevin Vess

Reputation: 341

Try creating a custom Must-Use plugin to use the switch_theme( $stylesheet ) function.

<?php

add_filter( 'template', 'wpse_49223_change_theme' );
add_filter( 'option_template', 'wpse_49223_change_theme' );
add_filter( 'option_stylesheet', 'wpse_49223_change_theme' );
function wpse_49223_change_theme( $theme )
{
    $domain = $_SERVER['SERVER_NAME'];
    $domain = str_replace('www.', '', $domain);
    if ( $domain == 'site2.com' )
        $theme = 'theme2';
    else
        $theme = 'theme1';

    return $theme;
}

Based on this solution at WordPress StackExchange.

Upvotes: 2

Related Questions