If Certain Date, Show CSS Stylesheet

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ccmovies
Forum Newbie
Posts: 15
Joined: Mon Oct 11, 2010 9:14 pm

If Certain Date, Show CSS Stylesheet

Post by ccmovies »

I am making a Wordpress theme and no one in the support forum knew how to do this, so I figured this would be a good place.

I want it so when it is a certain date, such as December 25th (Christmas) it will add the code

Code: Select all

<link rel="stylesheet" href="css/christmas.css" type="text/css" media="screen">
and when it is every other date it will not show that. How can I do this? I also want to do this for other holidays such as Thanksgiving. Thank you!
ccmovies
Forum Newbie
Posts: 15
Joined: Mon Oct 11, 2010 9:14 pm

Re: If Certain Date, Show CSS Stylesheet

Post by ccmovies »

Never mind it has been resolved using this code:

Code: Select all

<?php
if( date('d m') == '25 12' ) { ?>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/css/christmas.css" type="text/css" media="screen" />
<?php } ?>
User avatar
spedula
Forum Commoner
Posts: 81
Joined: Mon Mar 29, 2010 5:24 pm

Re: If Certain Date, Show CSS Stylesheet

Post by spedula »

Wouldn't javascript be a much better use for this?

either case try something like this:

Code: Select all


$christmas = date('j n');

if ($christmas == '25 12'){
	echo 'it\'s Christmas;
}
else {
	echo 'it\'s not Christmas';
}

Post Reply