• Resolved qnp9999

    (@qnp9999)


    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter qnp9999

    (@qnp9999)

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

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Conditional CSS Stylesheets’ is closed to new replies.