Forums

[resolved] Conditional CSS Stylesheets (3 posts)

  1. qnp9999
    Member
    Posted 5 years ago #

    I am working on a way to give multiple categories a style sheet. I know there must be a better way... but I am not the best with php.

    Here is the code I am working with:

    I thought this might work but apparently id did not.

    <?php if ( is_category ('1' ,'8' , '9' , '10' , '11' , '12' , '13' , '14')) { ?>
    <link rel="stylesheet" href="<?php bloginfo('url'); ?>/wp-content/themes/wrastle-10/threads.css" type="text/css" media="screen" />
    <?php } ?>

    So I have fallen back on the oh so un-elegant.

    <?php if ( is_category ('1')) { ?>
    <link rel="stylesheet" href="<?php bloginfo('url'); ?>/wp-content/themes/wrastle-10/custom.css" type="text/css" media="screen" />
    <?php } ?>
    <?php if ( is_category ('8')) { ?>
    <link rel="stylesheet" href="<?php bloginfo('url'); ?>/wp-content/themes/wrastle-10/custom.css" type="text/css" media="screen" />
    <?php } ?>

    etc. etc.

  2. qnp9999
    Member
    Posted 5 years ago #

    Found my own answer!

    <?php if ( is_category('1') || is_category('8') || is_category('9') || is_category('10') || is_category('11')|| is_category('12') || is_category('13')|| is_category('14')) { ?>
    <link rel="stylesheet" href="<?php bloginfo('url'); ?>/wp-content/themes/wrastle-10/threads.css" type="text/css" media="screen" />
  3. pizdin_dim
    Member
    Posted 5 years ago #

    The function is_category() doesn't support multiple categories. You can only test for either one id or one name, so the way you did it is correct.

Topic Closed

This topic has been closed to new replies.

About this Topic