• Hi,

    I need to load three different stylesheets depending on the page.

    I’ve added the <?php body_class($class); ?> tag to my body and have the following statement in the head:

    <?php if( is_home() ) { ?>
    <link rel="stylesheet" type="text/css" media="all" href="<?php echo get_stylesheet_directory_uri(); ?>/css/frontpage.min.css" />
    <?php } else { ?>
    <link rel="stylesheet" type="text/css" media="all" href="<?php echo get_stylesheet_directory_uri(); ?>/css/internal.min.css"
    <?php } ?>

    The problem is that I also have a global stylesheet that I need to load using the code:

    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />

    This works well if I load the global sheet before the others, but if I try to load it after the if statement WordPress just ignores it.

    I need to load it after the other styles so that things cascade correctly.

Viewing 1 replies (of 1 total)
  • Thread Starter c-m

    (@c-m)

    This isn’t working at all.

    I can see that the the home class is being added to the body tag, but wordpress is completely ignoring my statement loading the second set of stylesheets.

    <head>
    <?php if(is_home()){ ?>
        <link rel="stylesheet" type="text/css" media="all" href="<?php echo get_stylesheet_directory_uri(); ?>/css/bootstrap.min.css" /><link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    <?php }else{ ?>
       <link rel="stylesheet" type="text/css" media="all" href="<?php echo get_stylesheet_directory_uri(); ?>/css/bootstrap.css" /><link href="assets/css/bootstrap-responsive.css" rel="stylesheet"><link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    <?php } ?>
    
     </head>
    
    <body <?php body_class($class); ?>>

    I’ve two bootstrap stylesheets that I want to load. East contain different settings on gutters and widths etc.. One for my static homepage, the other for every other page.

Viewing 1 replies (of 1 total)
  • The topic ‘Multiple CSS files and if statements’ is closed to new replies.