Wordpress Theme Style Declarations

As some will know, I'm coding up a WordPress theme from scratch. The idea is to give lots of flexibility so that the theme can be easily modified using stylesheets alone.  Out of the box, it's fairly gaudy, but this is intentional as it encourages the modification! (Okay, I will ultimately make an 'okay' version based on the raw templates).

Anyhow, I thought to myself that it'd be great if css classes could be provided to allow pages to be styled differently depending upon category, tag or date. Lovely to be able to have a 'Christmas theme' that pops into being and goes away automatically without special coding and 'if' statements.

Therefore, I replaced the <body> tag in header.php with this code:

$today_month = date("m"); $today_year = date("Y"); echo "<body class=\"today_$today_year$today_month$today_day todaynoyear_$today_month$today_day year_$today_year month_$today_month day_$today_day todayyearmonth_$today_year$today_month "; if (is_tag()) { $current_tag = str_replace(" ", "_", single_tag_title("", false)); echo "maintag_$current_tag"; } elseif (is_category()) { $current_category = str_replace(" ", "_", single_cat_title("", false)); echo " maincat_$current_category";} echo "">"; ?> <!-- If a tag page, the tag is listed as a css class declaration in the form maintag_tagname --> <!-- If a category page, the category is listed as a css class declaration in the form maincat_categoryname --> <!-- There are also tags which update daily, letting the site owner have styles which only operate on certain days -->

On a tag page, it would do something like this: <body class="today_20081222 todaynoyear_1222 year_2008 month_12 day_22 todayyearmonth_200812 maintag_coding">

Thus, one could have specific CSS for a particular day (e.g. Christmas), or for a particular tag or category. All specific customisation can then be in the CSS.