I have two themes: “Default” and “Alternate”.

I’d like to place a link on my site that says “Switch to Alternate Theme”, which will change the default theme to the alternate and vice versa. A cookie would be set to save which theme the user is currently on, so when they return they will see the last theme they selected.

How do I change the theme on the fly in wordpress?

Thanks!

1 Answer
1

You can use Theme Switch and Preview.

If you are up for coding this yourself, you can use the template and stylesheet filters.

E.g.: to switch to Twenty Ten:

function custom_load_twenty_ten_template() {
    return 'twentyten';
}

function custom_load_twenty_ten_stylesheet() {
    return 'twentyten';
}

add_filter( 'template', 'custom_load_twenty_ten_template' );
add_filter( 'stylesheet', 'custom_load_twenty_ten_stylesheet' );

Leave a Reply

Your email address will not be published. Required fields are marked *