Again I will spend more time writing up a blog post about some little thing I did than actually doing the little thing. Maybe it’s my vanity, or just trying to capture how I go about my work. It’s my blog and I can blog what I want…

Sometimes I take these little self dares and see if I can fix some code or add a new feature in the time it takes me to eat breakfast. I was a wee bit over here, but oh well.

It all started with a tweet about the Ontario Extend Daily Extend site, which uses the DailyBlank WordPress theme I made.

Laura is referring to the leaderboard, something that really motivates some folks. Like Laura.

And she is right- the leaderboard shows she has done 66, yet if you click the link for her name, it shows quite a bit more.

The top participants are listed, with green bars indicating their relative amount of participating. Laura's name is about 7th showing 66 done.

With some checking, I saw the reason why- the current leaderboard just shows responses since January 1, 2018:

And if you go to the all time leaderboard you will see that Laura gets her full 148 count.

But it got me thinking that there might be a way to make it more clear, that on the link that displays one person’s responses, to indicate how far back in time it goes. And then the question, “how quick can I repair this?”

To step back a bit, data for each response to a daily extend in this theme is saved as a WordPress custom post type called “Response”. It saves the tweet text, it’s URL, the name of the person that tweeted. It also converts all @symbols in the tweet to tags, as well as any hashtags. Actually these are a custom taxonomy called hashtags.

The data looks like this in WordPress:

a sample response in WordPress, showing the tweet text as title, custom fields for the author and tweet IRL, plus hashtags

Having this in WordPress as data allows the theme to do things like display all responses by a person or a hashtag, as well as being able to generate the leaderboard. I’m kind of proud of how I have leveraged this.

So all I needed to do was add some code on the taxonomy-hashtags.php template that generates a taxonomy view to display the date of the oldest one it finds.

I first mocked up something that made use of the fact I already have a $wp_query object to use. I did some testing by doing a var_dump() of things until I drilled down to where it was, something like get_the_date('', $wp_query->post[$found_posts-1]->ID) (drawing from memory). I was testing this on a splot site not in use.

And it seemed to work, I was able to add a date since to the sub-title.

I then put the new code up to the Daily Extend site. It displayed a date, but it was only like a few weeks ago, not way back. I fiddled and blindly made changes (and doing the BAD thing of testing on a live site), and the date kept being way to recent.

Then it dawned on me I Was Doing It Wrong– it worked on my small test site because the number of responses returned was less than the breaks WordPress does in queries to make paginations. I was not getting the date of the oldest response, I was getting the date of the oldest one on the current page when there were more than 10.

So put the code gears in reverse. I already have a function in the theme that finds the oldest daily thing, so it was pretty quick to modify the function to be one that finds the oldest response for a given taxonomy term (e.g. a tag):

And in my taxonomy-hashtags.php template, I just need to add to the part that displays the number of responses found, change it from:

to be

And boom, we have a page for all of Laura’s Daily Extends that indicates that it includes hers to way back:

This also works for other tags like #sockspiracy:

That was my relatively quick fix, with one dead end and turn around.


Now that I look at it, I can see how it might be nice to pass a variable to the display, so it will show just the responses newer than a given date; this way the links to a person’s tweets on a leaderboard that is showing just the action since January 1, 2018 would display just those tweets…

I can see how to do this, it might take another breakfast to do.

Featured Image: Modified from Image from page 131 of “1930 Griffith and Turner Co. : farm and garden supplies” (1930) flickr photo by Internet Archive Book Images shared with no copyright restriction (Flickr Commons) by photoshopping in the label, a WordPress logo, and a little “PHP”. Kind of proud of this fiddling. Do not ask me why I spend time doing this.

If this kind of stuff has any value, please support me monthly on Patreon or a one time PayPal kibble toss
Profile Picture for Alan Levine aka CogDog
An early 90s builder of the web and blogging Alan Levine barks at on web storytelling (#ds106 #4life), photography, bending WordPress, and serendipity in the infinite internet river. He thinks it's weird to write about himself in the third person.


  1. Awesome! Now I know it is possible to collect and display data like this. Unfortunately, I don’t have time to do that to my course website yet … I still need to work through the pictures on the syndicated posts (I have the instructions). You inspire me. You are a true WordPress genius. People think I know things about WordPressing, but all I know I got from you … and I know how to do only a fraction of what you do. I hope we can have a Domain Boot Camp someday! Maybe January – a New-Year’s resolution theme.

Leave a Reply

Your email address will not be published. Required fields are marked *