Can’t switch to a child theme using filters template, option_template and option_stylesheet


In order to dynamically switch a theme in functions file (e.g. when wanting a different theme for a different domain, but same website), you use the following:

add_filter('template', 'my_switch_theme_for_domain');
add_filter('option_template', 'my_switch_theme_for_domain');
add_filter('option_stylesheet', 'my_switch_theme_for_domain');

function my_switch_theme_for_domain()
    return 'my-child-theme';

This does not seem to work when wanting to call a child theme. I get a white/blank page when calling a child theme, I have tried a few.

Is there some other code to switch to a child theme?

, , , Laurence Cope 3 years 2019-10-28T10:20:11-05:00 0 Answers 227 views 0

Leave an answer