WordPress.org

Ready to get started?Download WordPress

Forums

Create On Site with Multiple Styles (10 posts)

  1. designsbyjf
    Member
    Posted 2 years ago #

    I am trying to set up a site that will basically be a merged version of five old blog style magazine sites. I want all the content to be on one site, but when visiting anything that falls under one of the categories for 'magazine 1', it is branded with all its logos. When magazine #2, it is branded with its logos.

    Any suggestions?

  2. luckdragon
    Member
    Posted 2 years ago #

    first off, how do you determine which "magazine" they are going to?

  3. luckdragon
    Member
    Posted 2 years ago #

    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;
    }
  4. designsbyjf
    Member
    Posted 2 years ago #

    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.

  5. designsbyjf
    Member
    Posted 2 years ago #

    So, would I put this code in the category template file?

  6. luckdragon
    Member
    Posted 2 years ago #

    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');
    
    }
  7. luckdragon
    Member
    Posted 2 years ago #

    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)) {
  8. luckdragon
    Member
    Posted 2 years ago #

    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.

  9. designsbyjf
    Member
    Posted 2 years ago #

    that may be a better direction for me to go in. Could you please elaborate on this?

  10. luckdragon
    Member
    Posted 2 years ago #

    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" />
    <? }}?>

Topic Closed

This topic has been closed to new replies.

About this Topic