• minkowski

    (@minkowski)


    I’m building a site with multiple sections and want a different theme used for each of these sections. I’ve added new taxonomy so that I do have definite sections now and I’ve got as far as the admin menu for my theme switcher. What I have is a list of Sections and a select menu to choose the theme from, it’s pretty rudimentary but it works just fine.

    All I need to to find out how to switch the theme.

    I don’t know how to get WP to make the decision to load up a different theme before the currently active theme and how to load up that theme without it changing the currently active theme on the admin side. (as what happened with switch_theme, and then everything broke)

    essentially, I just want to know where to put my:

    if ( $section == ‘whatiwasexpectingtohappen’ ):
    changemythemeto( $section );
    endif;

    (or however it will work)

    I know it has something to do with add_action, or add_filter, or something but currently I’m just prodding around in the dark so any help would be fantastic.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter minkowski

    (@minkowski)

    OK, think I’ve got it.

    function autotheme_change_theme( $theme = 'default' , $section = 'theunexpected' ) {
    	if (  $section == 'theunexpected' ) {
    		$theme = 'section_one';
    	}
    	return $theme;
    }
    
    add_filter('template', 'autotheme_change_theme');
    add_filter('stylesheet', 'autotheme_change_theme');

    All going well this won’t need too much clearing out of buggy problems. And my goodness, hoorah for WordPress, this sort of stuff is so nicely easy. (once you know how)

    Thread Starter minkowski

    (@minkowski)

    Getting a little ahead of myself there.

    It works but I do have an error that I have no idea how to resolve at this point.

    Warning: Cannot modify header information – headers already sent by (output started at /blah/blah/blah/wp-content/plugins/autotheme.php:127) in /blah/blah/blah/wp-includes/pluggable.php on line 850

    Soooo, no idea what to do now. Any leads?

    Thread Starter minkowski

    (@minkowski)

    Well after finishing my tiny plugin, which now fully works, I took a look at that error message and lo and behold, it was whitespace at the end of the file. So, that’s it then. I have a website based on wordpress with multiple sections and themes that automatically apply when looking through those sections. All good.

    Well I say all good, what I mean to say is that I’ve written some of the ugliest code known to man to fudge a few things that I don’t fully understand. Not poetry, not at all, so while I’ll mark this topic as resolved any input into how to get term data from WP when reading a post would be helpful. What I have is a massive SELECT blah FROM blah INNER JOIN blah ON blah = blah WHERE blag after grabbing the post ID from $GLOBALS. If you’re not saying to yourself “that sounds reasonable” then post here and tell me how it could be better!

    ty

    Thread Starter minkowski

    (@minkowski)

    OK, just looking at this this morning I notice that I probably should’ve been a little more ready to check through what was actually happening. I’m not changing the theme, just the stylesheet. I suppose that I do very much need help on how to do that then. (unmarking Resolved, BAH!)

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Switch theme for visitor on condition’ is closed to new replies.