WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Custom CSS for Posts in a given Category (5 posts)

  1. inbloome
    Member
    Posted 3 years ago #

    Hello,
    I have read through some similar posts on here and I have to admit, I just can't seem to get the advice to work on the site I am building.... so I am hoping I can get specific advice to my predicament and code specific to my theme (arthemia free) and site.

    The site is now at http://staging.madwoman.com.au (note it's work-in-progress!)

    I have established a default CSS that I am happy with and then created a green.css for the Category Archive page for category-3 (aka Single Volunteers) and a white.css for the Category Archive for category-5 (no posts in this one yet.

    However, I cannot work out the steps to have each individual post (ie single.php) in Category 3 use the green.css.

    How can I make each post in Category 3 use green.css and those in Category 5 use white.css?

    I am doing this as a pro bono job, so I am so grateful for your assistance!!

    Justine

  2. inbloome
    Member
    Posted 3 years ago #

    'ello? anyone out there?

  3. inbloome
    Member
    Posted 3 years ago #

    Is it just me, or is it hard to get replies on this forum. Don't worry, I worked it out myself through trial and error. In case anyone else is interested, here is the code:

    <?php if ( is_front_page() || is_category( array( 1,4,6 ) ) || in_category( array( 1,4,6 ) ) ) { ?>
      <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/style.css" type="text/css" media="screen" />
    <?php } else if ( is_category( array( 3,9,10 ) ) || in_category( array( 3,9,10 ) ) ) { ?>
      <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/green.css" type="text/css" media="screen" />
    <?php } else if ( is_category( array( 5,11,12 ) ) || in_category( array( 5,11,12 ) ) ) { ?>
      <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/white.css" type="text/css" media="screen" />
    <?php } else { ?>
       <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    <?php } ?>
  4. ant1mazr
    Member
    Posted 3 years ago #

    great tip !
    can you tell me where do i have to put that piece of code ?
    thanks !
    ant1

  5. esmi
    Forum Moderator
    Posted 3 years ago #

    That code code won't work for another site. I suggest you post a new topic describing what you are trying to achieve.

Topic Closed

This topic has been closed to new replies.

About this Topic