3

I really would like to know if it's possible to change the style.css during the holidays in WordPress with PHP or Javascript.

so when it's Christmas Day, i want to change my style.css to christmas.css. But when Christmas is over i want to turn it back to the default style.css.

Normal Day       ---->    style.css
Christmas Day    ---->    christmas.css
After Christmas ---->    style.css

Can anyone help me?

1
  • 1
    Psuedo: if day = 25 december -> link christmas.css else -> link style.css
    – rpm192
    Commented Nov 21, 2018 at 10:24

2 Answers 2

2

If you include the CSS file with PHP then you can add a check that gets the date and changes it accordingly, as so:

$date = date("m-d");
if ($date == "12-25") {
  /* Include christmas.css here */
} else {
  /* Include style.css here */
}
1
  • Both are right but i need to give it Keydose for the fast responds.
    – Dionoh
    Commented Nov 21, 2018 at 10:37
1

In the <head> of your webpage, you could use this:

Change the $date to '11-21' to verify that it works.

<?php
  $date = date("m-d");

  if($date = '12-25') {
    echo '<link rel="stylesheet" href="/css/christmas.css">';
  } else {
    echo '<link rel="stylesheet" href="/css/style.css">';
  }
?>
1
  • Both are right but i need to give it Keydose for the fast responds.
    – Dionoh
    Commented Nov 21, 2018 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.