
It’s Christmas today! So what about wishing merry Christmas to your readers? In this simple recipe, we’ll see how easy it is to implement a “Merry Christmas” message in your WordPress blog.

It’s Christmas today! So what about wishing merry Christmas to your readers? In this simple recipe, we’ll see how easy it is to implement a “Merry Christmas” message in your WordPress blog.
To achieve this very simple recipe, simply paste the following code anywhere on your theme. The "Merry Christmas" message will be displayed only on Christmas day.
<?php
if ((date('m') == 12) && (date('d') == 25)) { ?>
<h2>Merry Christmas from WpRecipes!</h2>
<?php } ?>
By the way, I wanted to wish a Merry Christmas to all of you, and saying a big THANK YOU for your support and readership!
11 Responses
if ((date(‘m’) == 12) && (date(‘d’) 25)) { ?>
Missed the ‘==’ in the second condition?
Damn, you were right! I should avoid drinking wine before writing recipes, even on Christmas eve
Just wondering how I could get the timezone setting of wordpress so I could check the date relative to where I am and not where the server is at. Thanks!
And a Happy Chanukah to all!
We should be thanking you for the delicious meals you share with us :p
And by the way, how can I add multiple statements, like for example, Christmas Day, I want this message and then on another date I want another message?
php date() doesn’t take the server hour?
I think a better idea is to have a little JS hack to take computer’s time
just a small idea, because of the GMT time differences
– you got the point I guess
)
Yeah, I’m using a JS hack on my blogs to take the computer’s current time, but this is obviously a lot simpler, and would take less time to do.
So you agree with me :p
Best solution is JS related
And, if you planned ahead, you could throw in multiple if statements and put in all the holidays… probably at that point, though should read them from a MySQL table as they could be easily edited, added to, etc..
If you wanted to get even more complicated, you could create a series of holiday-themed headers linked to the holiday record and display them on a particular date… a whole year of holiday wishes in one fell-swoop
Sounds like a plug-in opportunity.
Trackbacks: