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.

  • 4
    I can't imagine in what scenario this would be easier than accommodating the different layouts/styles in your primary active theme. I suspect you are making life hard for yourself with this.
    – vancoder
    Commented Apr 5, 2013 at 16:49
  • Consider that I have both themes previously made and ready. I just want to load the second theme for my categories and I don't want to spend time on accommodations. Thanks.
    – 2hamed
    Commented Apr 6, 2013 at 5:37
  • Ehem, nobody knows how?
    – 2hamed
    Commented Apr 7, 2013 at 5:01

1 Answer 1


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.