I need to load a completely different theme for my categories. My search came up with switch_theme
function but it changes the theme permanently while I only need the theme change only occur on my category pages.
Then I found this.
add_filter( 'template', 'my_change_theme' );
add_filter( 'option_template', 'my_change_theme' );
add_filter( 'option_stylesheet', 'my_change_theme' );
function my_change_theme($theme)
{
if ( is_category() )
$theme = 'theme_for_cats';
return $theme;
}
The problem with this one is, it only loads the correct stylesheet. The markup stays the same as my default theme.
Any help is appreciated.
Ok, after some consideration and tinkering I could get it to work.
The reason it wasn’t working was because the needed procedures for loading a template kick in long before the the parser gets to
functions.php
of the theme. So to overcome this I had to bring the code into the plugins’ section.By creating a plugin the needed filters are called in time therefore the theme gets changed correctly.