Tag Archives: Blog

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.

Themes

The observant may have noticed that the look of this site has suddenly got rather gaudy. There is a good reason for this – I’ve been creating a WordPress theme which I want to be as flexible as possible. I.e. a ‘bare’ theme, which can then be styled easily with css.

I know these themes already exist, but I wanted my own, m’kay?

The reason for the gaudy colours? Testing. I wanted the default colours to be fairly obvious, with each main element being distinct so that I could be sure that I had the no typos in the CSS selectors.

I’ll leave the theme running for a little while, I’d be interested to hear about any usability issues (other than the horrible colour scheme).

The theme should be fully widgetised, it should have comment threading, avatars and so on.

The theme should be fluid and resize gracefully, as screen width reduces, the images reduce whilst keeping aspect ratio.

Things I know I want to fix – some of these are purely ‘behind the scenes’:

  1. I want, at most, one sticky post on the front page. At the moment, it’ll put any number on.
  2. I want to have a tags page which shows the tag cloud.
  3. Behind the scenes, the entry formatting uses the same template, called when needed by index.php and archive.php. I need to get the single.php template to use this as well in order to minimise maintenance (requires some ‘if’ statements).
  4. Do I *need* single.php and archive.php once I’ve done that?
  5. Author pages, ideally automatically pulling in gravatars.
  6. Decent 404 page
  7. The comment form gets screwed up on a narrow screen and doesn’t resize gracefully. I don’t know why.
  8. I want the theme to be accessible. I.e. Good for screen readers and the like. I have no way to test this however, so if you know anyone with a screen reader, please do point them in this direction and ask them to comment (or, pass on their comments should it *really* be unusable).
    1. Is the order of elements okay?
    2. aural stylesheet hasn’t been done, for me, that’d be coding without testing – I would want a sheet though!
    3. The tags/related tags stuff – does there need to be a way to, ideally optionally, skip that for screenreaders…. I wonder how (without introducing new screen cruft)
  9. I’ll then package up this rough theme for release, create a duplicate and change the look and feel to customise it. If I find that I have to customise anything other than a stylesheet, I’ll need to amend the ‘raw’ theme.

Things I’m unsure of:

  1. I’ve appended categories to tags (with a different class for styling)
  2. Do I want to keep the related posts thing? It relies on a plugin, so isn’t essential for the theme (plugin may be disabled as a recent update caused a problem behind the scenes… I hope I remember to remove this sentence when fixed, but I’ve couched it as a conditional just in case)

Number 10 and WordPress

Number 10 has modified their site to use WordPress, and it does look good.

At first.

Unfortunately, they’re not using the full power of WordPress – I note in particular that comments are switched off for everything at the same time that they’re talking about ‘dialogue’.

What I find particularly amusing is that the first, most obvious link on their homepage, which promises us "Number10TV" and the ability to "watch the PM’s introductory film." gives this result:

I think the phrase they need is ‘Whoops’.

Epic Fail. Says it all really.

Original heads-up from ocaoimh.ie

When starting from scratch (as opposed to migrating a site over from another URL or software system), there is really little excuse for broken links in WordPress, especially when you’re paying developers to manage it for you. Hundreds of thousands of people, if not millions, manage it quite comfortably…. and there is especially no excuse for a broken link on something that takes up half the screen on the homepage – the first thing people see.

Update: The 404 has been fixed.