You can use the stylesheet
filter to change the active child theme:
add_filter( 'stylesheet', function ( $theme ) {
return 'twentytwelve';
} );
If you would like to change the active parent theme, you need to use the template
filter as well:
$theme_callback = function ( $theme ) {
return 'twentytwelve';
};
add_filter( 'stylesheet', $theme_callback );
add_filter( 'template', $theme_callback );
Thread Starter
spok72
(@spok72)
thank you very much for your quick reply. I will hook this code and check if it works.
Regards
Thread Starter
spok72
(@spok72)
Works but only temporarily. When I click on any link, after passing back the old template.
The change is not permanent within the page being viewed
Hi @spok72,
If you’d like a more permanent change, then you can use the switch_theme
function.
Keep in mind that this function has a permanent effect, so you don’t need to run it on every page load. You could use it in an only run once snippet, or have some sort of check for when you want to use it.