My client would like the background & header colors to switch depending on terms within the custom taxonomy 'Grades'. These terms are kindergarten, first grade, second grade, etc... (all through twelfth grade) and are associated with a custom post type 'projects'.
I've set up the menu so that each term in 'grades' has it's own page. These are not actual pages that you'd find in the dashboard. These pages are just an archive-type pages specific to each grade.
I found a great blogpost regarding contextually changing the stylesheet depending on the page name ( http://justintadlock.com/archives/2009/07/27/contextually-changing-your-themes-stylesheet ). My php understanding is a bit limited and I can't figure out how to edit this code so that instead of switching stylesheets because of a page's name, it is triggered by an array of terms within the custom taxonomy 'grades.'
I want to switch stylesheets on archive pages for custom taxonomies. The switch should be triggered by a custom taxonomy's terms. IE: The Kindergarten page is actually an archive page for 'kindergarten' in the the custom taxonomy 'grades' I have 13 terms associated with 'grades' > kindergarten, first grade, second grade, third grade, etc...
IE: I would like the background image and heading colors to change. Green for kindergarten, first grade, second grade, third grade... Orange for sixth grade, seventh grade, eighth grade... Purple for ninth grade, tenth grade, etc...
I found a solution that works only for archive pages and taxonomies: is_tax function.
add_filter( 'stylesheet_uri', 'my_stylesheet', 10, 2 );
function my_stylesheet( $stylesheet_uri, $stylesheet_dir_uri ) {
if ( is_tax( 'grades', array('term_name' => 'Kindergarten', 'First Grade', 'Second Grade', 'Third Grade', 'Fourth Grade', 'Fifth Grade' ) ))
$stylesheet_uri = $stylesheet_dir_uri . '/style-elemen.css';
elseif ( is_tax( 'grades', array('term_name' => 'Sixth Grade', 'Seventh Grade', 'Eighth Grade' ) ))
$stylesheet_uri = $stylesheet_dir_uri . '/style-elemen.css';
return $stylesheet_uri;
}