WordPress.org

Support

Support » Themes and Templates » Change CSS according to Date

Change CSS according to Date

  • Hello! I am making a WordPress theme that will change its colors and graphics according to the date. For example, if it is December 25th, Christmas, it will change to Christmas colors and Christmas graphics.

    So, I figured I can change the CSS file according to the date. However, I don’t want to manually change it, I would like PHP or something to change it for me. How can I achieve this?

    For example, PHP realizes its December 25th and adds a stylesheet link to css/christmas.css. Then on December 26th it removes it so it uses the default css. Thank you very much, I highly appreciate it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Michael

    @alchymyth

    Forum Moderator

    for instance, in header.php, after the line with:
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />

    you could add this kind of code:

    <?php
    if( date('d m') == '25 12' ) { ?>
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/css/christmas.php" type="text/css" media="screen" />
    <?php } ?>

    http://php.net/manual/en/function.date.php

    untested

    Awesome! I will test this and let you know if it works or not.

    Yes it works! Thank you so much!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change CSS according to Date’ is closed to new replies.
Skip to toolbar