• Hello, kind souls

    Is it possible to effect some distinct changes to look and feel of a WP theme by defining functions/routines to load a different style sheet (css) based on category slug/id, and a different loop for each catregory, as called by the site main menu?

    So, not being a programmer, I am asking whether something already exists that will do this job, or whether the following seems feasible.

    To load a category style sheet add to function.php —

    <?php if ( is_category('foo', 'myTheme') ) {?>
      <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/foo.css" type="text/css" media="screen" />;
    <?php } elseif ( is_category('bar') ) { ?>
    <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/bar.css" type="text/css" media="screen" />;

    etc…

    and then this to the beginning of the loop on index.php —

    if ( is_page('foo') ) {
      query_posts('cat=1');
    } elseif is_page('bar') ) {
      query_posts('cat=2');
    }

    etc …

    The intended outcome is that all pages in category foo display with foo.css (HTML markup stays the same for pages regardless of category), and a link in the menu to category foo will load an index diplaying only posts from category foo. And so on for six other categories.

    Has anyone seen examples of this working successfully, or documentation I may have missed in the Codex, or tips from some bright person who’s already done it?

    Would hate to re-invent the wheel to come up with a square one. 🙂

    Am developing offline in XAMPP, so no URL to illustrate what I mean.

    Regards
    Peter

  • The topic ‘loading separate category css and loops’ is closed to new replies.