Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
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 Apr 5 '13 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. –  Hamed Momeni Apr 6 '13 at 5:37
    
Ehem, nobody knows how? –  Hamed Momeni Apr 7 '13 at 5:01

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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