first off, how do you determine which “magazine” they are going to?
if you are differentiating them by category, it would be something similar to this:
add_filter('template', 'magazine_style');
add_filter('option_template', 'magazine_style');
add_filter('option_stylesheet', 'magazine_style');
function magazine_style($theme) {
get_the_category();
if ( in_category('Magazine A') ) {
$theme="MagazineA";
} elseif ( in_category ('Magazine B') ) {
$theme="MagazineB";
} elseif ( in_category ('Magazine C') ) {
$theme="MagazineC";
} else {
}
return $theme;
}
Each Magazine would be a category. I would like to style all posts, category and sub-category pages for the living magazine to be styled with livingStyle.css and all that falls under the business magazine to be styled with businessStyle.css.
Let me know if that is what you were trying to determine.
So, would I put this code in the category template file?
you would have to put it in the functions.php file (you might have to put it in the functions.php file for EACH theme, in which case, you might have to check if it’s defined)
if (!function_exists("magazine_style")) {
function magazine_style($theme) {
get_the_category();
if ( in_category('Magazine A') ) {
$theme="MagazineA";
} elseif ( in_category ('Magazine B') ) {
$theme="MagazineB";
} elseif ( in_category ('Magazine C') ) {
$theme="MagazineC";
} else {
}
return $theme;
}
add_filter('template', 'magazine_style');
add_filter('option_template', 'magazine_style');
add_filter('option_stylesheet', 'magazine_style');
}
also, you might have to list each category individually (like sub-categories)
$magazineAcats = array("Magazine A","headlines A", "TOC");
$magazineBcats = array("Magazine B","headlines B", "Sporting Events");
if (in_category($magazineAcats)) {
also, if they all use the same theme, and you are just changing the .css file, there’s another albiet similar way to do it. let me know if that’s the direction you need.
that may be a better direction for me to go in. Could you please elaborate on this?
same concept, only since there’s only 1 theme, you only need to put it in that theme’s functions.php file
add_action('wp_head','magazine_style');
function magazine_style() {
global $post; get_the_category();
$magazineAcats = array("Magazine A","headlines A", "TOC");
$magazineBcats = array("Magazine B","headlines B", "Sporting Events");
if (in_category($magazineAcats)) { ?>
<link rel="stylesheet" href="<?php bloginfo('template_url')?>/magazineA.css" type="text/css" />
<? } else if (in_category($magazineBcats)) { ?>
<link rel="stylesheet" href="<?php bloginfo('template_url')?>/MagazineB.css" type="text/css" />
<? } else { ?>
<link rel="stylesheet" href="<?php bloginfo('template_url')?>/style.css" type="text/css" />
<? }}?>