The MU forums have moved to WordPress.org

Load home.css ONLY if you're on the homepage? (8 posts)

  1. hempsworth
    Member
    Posted 17 years ago #

    Hi,

    I'm sure there's a really simple way to do this, but I searched and couldn't fine anything.

    How do I only load a home.css file if the current page IS the homepage? It's probably along the lines of:

    	<?php if ( WHAT TO PUT IN HERE?) { ?>
    	<link rel="stylesheet" type="text/css" media="screen" href="<?php bloginfo('template_directory'); ?>/home.css" />
    	<?php } ?>
    

    Thanks,
    Alex

  2. drmike
    Member
    Posted 17 years ago #

    homepage as it the homepage for individual blogs or the home.php file for the main blog?

  3. hempsworth
    Member
    Posted 17 years ago #

    For the main blog only

  4. ceejayoz
    Member
    Posted 17 years ago #

    Your best bet is probably:

    
    if(is_home() && ($_SERVER['HTTP_HOST'] == 'www.yourdomain.com' || $_SERVER['HTTP_HOST'] == 'yourdomain.com')) { }
    

    Won't work if you're not using subdomains, in which case you'll need slightly different code.

  5. hempsworth
    Member
    Posted 17 years ago #

    Thanks, Its working great :)

  6. suleiman
    Member
    Posted 17 years ago #

    why not just hardcode it into the theme that powers the homesite?

    Or are you letting your users also pick the home theme?

  7. hempsworth
    Member
    Posted 17 years ago #

    The installation is for an e-magazine, so there aren't any users as such so I think I'll just hardcode it.

  8. ceejayoz
    Member
    Posted 17 years ago #

    That'll work to - just use is_home() to check if it's the home page. Enjoy!

About this Topic

  • Started 17 years ago by hempsworth
  • Latest reply from ceejayoz