Using WordPress as a Building Log

Who doesn’t like WordPress? It’s fast, stable, and ubiquitous. I have used WordPress to power this building log, and it does a great job. There are so many folks using WordPress in so many ways that online help is abundant- which is part of why I’ll direct you to those sources for questions about how to install the software and implement a theme.

Once you have done those things, you’ll find one key feature missing, and that is hour tracking. How can you log hours with wordpress? I got around this with a little help from my programming friend Wesley. This strategy assumes that you are using a WordPress Post for each building session. By the way, did you know that you can publish a post with any date? I use this feature to batch post building log entries after the fact. I select the date and time that corresponds to the end of the building session, and that keeps everything organized. When you are composing the post for your building session, scroll down to the “Custom Fields” dialog at the bottom. Create a custom field called “Hours” and enter the decimal version of the number of hours you have logged with that post. This will store your build time in the WordPress database, right beside your post content.

Now, we just need to fetch that number from the database when we want to show the number. In your child theme’s style sheet (stop right there if you don’t know what a child theme is- Google it, and make one, because if you make these changes in your main theme files and then update the theme, the changes will be overwritten), create the following:

.post-hours {
[insert your css here]

.hours {
[insert your css here]

Just be sure to replace [insert your css here] with your css styling that you would like to use. is a great source for CSS syntax.

Now, decide where you want the number of hours to show up, and find the right file to edit. This is going to vary from theme to theme. Most themes use a file like post.php or content.php to display posts. You may want the number to show up there, perhaps in the post meta data as I do on this log. You may want it in a sidebar. The key is to find the file that you think you want it in, copy that file into your child theme, and then put some sort of sample flag (perhaps a word like “Fish Sticks”) in place to make sure you are controlling what you want to control. If your fish sticks are showing up where you want for your hours to show up, then that means you are editing the right file.

<div class="post-hours">
<span class="hours">Hours</span>
<span class="hours"><?php
$thesehours = 0;
$thesehours = get_post_meta($post->ID, "Hours", true);
echo "Logged This Session: $thesehours";
?> </span>

This was the relatively easy number to display. If you want to change the text, carefully edit the “Logged This Session: area without deleting the preceding quotation mark or the $ in front of $thesehours.

To display the total hours for the project, use the information here.

For a while I had a different method listed here, but it stopped working after a WordPress update.

As with everything else on this website, the above information may be totally wrong. Definitely back up your files and database before you attempt to implement the above changes!