Graphene Goodness

It’s about a month since I switched to the excellent Graphene theme, and so far it’s still making me happy. But there was one little thing I didn’t like.

I like the calendar-style date block the theme uses, but it doesn’t include the time of the post, which is something I like to display, if only to excuse any incoherence in posts made a little too late in the evening. So, today, I thought I’d have a look at adding the time. My first thought was to adopt a traditional approach, and edit the function that outputs the date. That was easy enough, but the trouble with that is that I’d either have to create a child theme (overkill for one little edit), or have to recreate my changes every time the theme gets updated (annoying, and I’d forget).

Then I looked at the theme options again, and realised that I’d just wasted my time. I’d seen the heading Action Hooks Widget Areas, but hadn’t quite registered what that meant, or how insanely clever it is. Basically, for numerous areas of the theme (pretty much any location you can see on screen), “hooks” are enabled, which is a generally useful programming trick to let functions insert content, or change content, or do other Clever Things. The difference in Graphene’s case is that you can select any of these hooks, tick a box, and you’ll then be able to insert any WordPress widget in the area corresponding to that hook.

And what does that mean? Well, if you use a text widget, or a PHP widget, you can stick any bit of text or code just where you want it, without having to edit any theme files or going to the trouble of creating a child theme. Brilliant.

I selected the graphene_post_meta hook then went to my widgets settings, where I added a new PHP widget (I use Otto’s PHP Code Widget for such things) with this simple bit of code:

Posted at <?php the_time('G:i'); ?> 

as the content.

Note that you’ll need to use the_time() rather than the_date(), as the latter will only show output for the first post displayed for each day.

And this pretty much sums up why I no longer bother attempting to create my own themes.

One thought on “Graphene Goodness

  1. Pingback: Now that’s what I call support : Losing it

Comments are closed.