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
homepage as it the homepage for individual blogs or the home.php file for the main blog?
hempsworth
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.
hempsworth
Member
Posted 17 years ago #
Thanks, Its working great :)
why not just hardcode it into the theme that powers the homesite?
Or are you letting your users also pick the home theme?
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.
That'll work to - just use is_home()
to check if it's the home page. Enjoy!