That’s meant to be blank like _________ like make your own site that operates like the DS106 Daily Create. I’ve been mumbling about it for like months, and sat down to start tinkering about a week ago.

I think most of the parts are in place, I’d say it is several Greek letters prior to “alpha”, and am writing now to check in as a progress to myself post. Much of what is left is cosmetic and structural layout, documentation, and much more testing.

The idea is that like the Assignment Bank Theme you can create a kind of site that generates any kind of Daily task, assignment, challenge. A Daily [fill in the blank]!

Unlike the The Daily Create, you do not have to respond by uploading and tagging to a specific social media site. Whatever you do as a response, you simply tweet to a specific twitter account the site owner creates, and include the link and a hashtag associated with the Daily _______.

This is what I saw as things to figure out, and what I got done last week:

It’s current test site is living now at and likely will generate PHP error codes as I work on it. I have the current code on github as well.


I modified the home page template to display just the most recent item (like the Daily Create).

What follow is an excruciatingly long, code-filled post. I’m putting it below the fold, so if you are reading this in one of those antique RSS readers, you might have to click through to see it on my blog (which, I must say, is looking gorgeous in its new clothes).

Daily Blank Options

Like the ds106 Assignment Bank Theme, I use code based on Aliso The Geek’s WordPress Settings API Tutorial to generate an Options screen. My theme adds a menu item to the Dashboard, under Appearance, and to the to Admin bar to link to the screen where you configure your site. This will be organized a bit better, but for now, I just aim getting things working.

First part of options

First part of options

These settings include:

  • A name for the things on your site my Demo is a “Daily Blanl”, for ds106 it might be “Daily Creatr”
  • Twitter account This is the account people will reply to when they want to submit something. I probably will not build in automatic tweeting; but will recommend what we do on The Daily Create, using dlvr to tweet from the site’s RSS feed (auto tweeter plugins either do not manage scheduled posts well OR if they do, they do not allow you to customize the message). For my demo site, I resurrected good old @auntysocial one I used previously to tease my friends. You will want to make some new account to be the “listener”
  • Default Tweet is actually the message I code into the Tweet this buttons on the site.
  • Base Name for Tags is what the site uses to define each “thing” and to form the URLs, tag things internally. For The ds106 Daily create, this would be tdc so Daily Create number 992 is identified by tdc992; in the Daily Blank this would also be the required hash tag, e.g. #tdc992
  • Starting Tag Numbers For the most part, you will just start at 1, but if we used this for a new version of DS106 Daily Create, we could bump the starting point to keep a consistent count system.
  • Front Image Upload or choose via the native WordPress uplaoder the image that is used on the front of the site. Normally this is the most recent post’s featured image, I recoded the template to use the image specified in the options.

The next set of options…

And now, for the rest of the options...

And now, for the rest of the options…

  • When to Publish The time of day when a new item is published. The site allows you to queue in advanced as many of this as you like, they are set to be scheduled posts, meaning they are automatically published to the world when the publish date/time passes.

    Working with time is always insanely complicated. Most people never change their WordPress settings from the default UTC time. I came up with a clever (I think) way to take the input, you can enter a human time like “5 o’clock” or “5pm” or “17:00”. When the options are saved, my script converts that to a computer time (PHP strtotime function) which, if it can figure out what you intend, gives you that time in the current day. To get an internally consisten time, the date function echos it in simple hours:minutes format.

  • [code lang=”php”]
    $timeofday = strtotime( $input[‘dailytime’] );

    if ($timeofday) {
    // valid time of day
    $input[‘dailytime’] = date(‘H:i’, $timeofday);
    } else {
    // uh oh, we are stumped, return an error
    $input[‘dailytime’] = ‘Invalid format! try \’13:00\’ or \’1pm\’ for 1 o\’clock’;

    The rest of the form is stuff to set up a captcha; this comes into play when I adda form for allowing site visitors to submit a new idea.

    What happens here with this options structure, is I have available in my code, variables for these values, like dailyblank_option('twitteraccount') gives me the name entered as a twitter account or dailyblank_option('dailykind') is the name of the kind of thing.

    See all of the options code on github. It’s called into action in my theme’s functions.php

    [code lang=”php”]
    add_action( ‘init’, ‘dailyblank_load_theme_options’ );

    function dailyblank_load_theme_options() {
    // load theme options Settings

    if ( file_exists( get_stylesheet_directory() . ‘/class.dailyblank-theme-options.php’ ) ) {
    include_once( get_stylesheet_directory() . ‘/class.dailyblank-theme-options.php’ );

    Authorizing and Talking to Twitter API

    This was all completely new ground for me, and getting to where I am was the usual brute force method:

    1. Look for code/plugins.
    2. Figure out what to modify for my site.
    3. Test and break.
    4. If by some miracle this works, go celebrate.
    5. Else Go to [2]

    There are a number of plugins to set up a means to authenticate a twitter account to do stuff on a WordPress site, most are meant for ones that let you tweet out posts. I found Storm Twitter for WordPress which does nothing more than provide a settings page to enter your twitter account credentials, and function you can use in your code to request results from the twitter api.

    You of course need to create a twitter account (where I wasted an hour creating one and never managed to get it set up because I had a typo in my own email. C’est la typo) and login into the developer side of twitter to create an app (look for this in the documentation to be).

    You then need to copy the four strings of alphanumeric gobbledygook to the Twitter Feed Auth screen the plugin adds


    When you save… nothing happens. You need to create some code that makes the requests to twitter. The Storm Twitter class out of the box was not what I needed; the call it makes to twitter is to get a user’s tweets. I needed mine to get the replies to my twitter account, so I had to edit the Storm Class file near line 154 to change

    to read

    because I want the mentions my account gets, each time someone tweets to @auntysocial

    But more than that, once I get mentions, I do not want them all. I only want ones that include a URL AND a hash tag that has a form of #thedailyXXXX

    The way I go about this is I create a blank page on my site with a slug name of “debug”, and put my test code in a theme template named page-debug.php. Then I just load that page in my wordpress site, and after stomping out the PHP errors, I debug. And debug. And debug. I use the var_dump() function to look at variables. IN fact, I create my own function to echo this out, putting the results in pre tags makes it readable.

    [code lang=”php”]
    // handy dandy debug dumper.
    function cogdogbug($var) {
    echo ‘


    My first effort was to find out what’s returned by the twitter API in the mentions_timeline. The API is well documented and you can find specifically what the timeline call returns. My first step was to send a bunch of tweets to my account, and then experiment with the request via the Storm Twitter class.

    Through trial and much error, I found I had to add a few options to the function that retrieves the tweets

    I am telling getTweets to use the mentions timeline for the account listed in my options page, to look through the 100 most recent items (200 is the max). The last array are the extra API values I need to give it; first is to say I do want replies (the default is not), and not to “trim the user” meaning when I get reference to a user, I want info such as their twitter handle (otherwise all you get is an id).

    Okay, that’s mumbo jump. Basically I am able to ask twitter for info about all the replies (aka mentions) to @auntysopcial, anyone who has included her handle in a tweet.

    What’s in a Tweet?

    Just to blow your mind a bit, while a tweet is limited to 140 characters, a whole lot more stuff is set. This call I am using is returning 5540 characters of data! This showed me where in the results things were that I needed, like the hashtags used in the tweet, the urls used in the tweet, the user name of the person who responded.

    My function for walking through this had to parse out the items, and process it only if it met the conditions of including a hashtag similar to my basetag and if it had at least 1 URL

    The add_dailyblank_responses() function turns each tweet found into a custom content type (described below)- this uses standard built in functions WordPress has to create posts via code

    The variables in the array sent to wp_insert_post() match the custom content type the site creates (described below). I want to avoid creating duplicates of tweets; I experimenting with adjusting the API to use the capability to check tweets after ones already read, but I did not get it to work.

    Instead, my design for the Response type creates a tweet item identified by its unique twitter id (this is the “slug” or the part of its url name). So my function will skip a tweet if there is already an existing item previously created.

    Can I get the site to check twitter all by itself?

    There are built in functions in WordPress core to do this; I’m still testing it out. It seems it needs triggers of visits to your site to run the updates. It’s a matter of setting up what are known as “scheduled events” and defining an interval to do this.

    I can see that some sites may not have sufficient visitors to trigger this, so I am looking at adding a manual update, as well as creating a URL that can be called from a cron script.

    Storing Tweeted Responses as a Custom Post Type

    Knowing how to create, manage, and use Custom Post types is the huge leap in using WordPress for more than just organizing blog posts. It lets you define kinds of content you can display, search, sort, create, delete that are like posts (with a title, description, etc) that exist independently of posts.

    It is da bomb for wordpress developers.

    I’ve been using them for a few years, and while you can shortcut the process with various plugins, you might get limited to the capabilities of the plugins. I’m an old school code welder; I try where possible to build ’em myself. The Codex has more than sufficient documentation, and when things get sticky, there are searches that find many results in groovy places like Stack Exchange.

    Along with custom content types, you can create custom classification schemes that act like post categories and/or tags- these are custom Taxonomies. I sketched some of this out on a piece of now lost paper, but I knew I needed a content piece that would house the tweets I harvested from twitter.

    Here is what one looks like, I call it a Response

    single response

    This is what I ended up with:

    • Title: I put the text of the tweet in the title.
    • Description: not used! I do not need it.
    • Publish Date: the date/time when it was tweeted
    • Slug or Short Name The twitter id for the tweet, this is unique, and serves well for the part that defines the URL the content generates
    • Custom Fields: I could have made these additional kinds of content, but since they are never seen, using custom fields is good enough. This extra data stored from each tweet:
      • tweet_by the twitter user name of the person who replied
      • tweet_url the full URL for the tweet (used to display it when we show one)

    Here is how that is generated in functions.php:

    There are also tags associated with this kind of content, but they are stored separately from the normal blog post tags, this is a custom taxonomy I made called Hashtags. What I am adding to each captured tweet is one of these for each hashtag in the tweet; I also add one (with the “@” in front) for the twitter name on the account. This allows me to create a link that can show all harvested tweets from one user (example).

    This way I have templates made that generate views of all tweets with one of the site’s defined tags, e.g. for thedaily1, but lets me create views for any other hash tags user might use. e.g. ccourses. The latter means those that use the site can ask for other hash tags, e.g. like a course tag.

    Here is how the taxonomy is created functions.php:

    I even got fancy, and modified the code that displays the Responses (equivalent to All Posts) to include columns that display the value of the custom field with the tweeter’s name (linked to their profile in twitter):

    responses view

    This is how I managed to do this.

    And it means on an individual Daily Blank, at the bottom, I can display all the responses (using the specified tag). This requires a custom loop inside the single.php template.

    What has to happen here is we have to do is get the tag associated with a single post, and run it through a custom query on the response type to get the responses that have the same thing as a Hashtag type. The magic on displaying the tweet as something more than text is to use the twitter URL we stored as a value we pass to the wp_oembed_get() function letting WordPress do the auto-embedding.

    Turning an Ordinary Blog Post into a Daily Blank

    Each Daily Blank is a normal blog post. Well, normal enhanced. The extra post editor box I add, allows you to trigger the features:

    • It gives the post a unique tag, the next one in the series. If your most recent one is thedaily345 it makes the next one you make tagged thedaily346.
    • It gives the post a scheduled date to appear, depending on the time of day you set as an option. If thedaily345 is set to publish on December 12, 2014; the new one will be set to publish December 13, 2014.
    • It appends a short instruction string as the directions telling the sitre visitor who to tweet it to, and what tag to use.

    In creating these, we can do them as we do normal blog posts, we start to write them. As I start with a title and the description I want to use, WordPress is already saving it as a draft (notice the URL it is using is based on the title):

    (click image for el biggon version)

    (click image for el biggon version)

    Note the box in the upper right; this is a Custom Meta Box I added to appear on all posts. It has the next tag available. Once you get a new post set up, the first time you click Save Draft. The script called by the custom meta box changes a few things- it adds the tag, changes the short url, sets the scheduled date/time when it will be available and appends the instructions.

    (click the image to see the full one in all it's glory)

    (click the image to see the full one in all it’s glory)

    You can continue to edit as you see fit. It will be saved a a schedule post, meaning visitors cannot see it until the schedule date has passed. Like the DS106 Daily Create, this allows you to create a long queue of things in advance.

    Once published, it appears on the site:

    published daily blank

    Where, if you will visit this one, already has a test tweet I sent it.

    I’ve already saddled this post with way too much code; look for it in functions.php under the area labeled Editing Meta Box – The thing that makes the daily magic. It needed custom functions to find the last tag used, and the date of the last created item.

    Tweaking the Admin Dashboard

    Since the posts are not really posts, my design aesthetic tickled me to figure out how to modify the menu names used in the WordPress Dashboard. Previously, I had used the WordPress Admin Editor plugin. What I find is that 90% of the plugins are front ends for stuff that’s in the core code.

    I found most of what I needed in a post from Revelation Concept. This lets me change the left side menus that normally say “View Posts”, “Add Post”:

    new daily blank add menu w scheduled

    as well as to put it under the top + New menu:

    new menu

    Also, using some help from the WordPress Codex I was able to add a sub menu item to the left menu to link to the Scheduled posts. Here’s yer code, dude!

    Slick, eh?

    What’s Next?

    Things are still in development. And it’s not quite fully tested. On my list is:

    • Add a form so visitors can submit a new Daily Blank like the Daily Create, this come in as Drafts. As a site admin, you can edit, and trigger the activation via the Custom Meta Box. This is pretty easy, I got good in the last project at adding forms that do not need fancy plugins to work.
    • Figure out Ajax Post Loading so any archive or list of responses can have a “show more” button that adds another set. This is new territory for me, and really should be in the assignment bank template to load the responses and tutorials. I am looking to this tutorial to help
    • Add a Header Banner Editor so the theme can have a consistent top mast.
    • Everything Else I cannot Remember. Oh yes, documentation to; which for now looks like:
    • Everything Else I forgot.

    Are you still reading?


    If this kind of stuff has value, please support me by tossing a one time PayPal kibble or monthly on Patreon
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. Still reading and I’ll read and again:) Great stuff Alan. Some stuff I’ve been dipping my toes in, some stuff I’ve been dreaming about and then a whole lot more. Envelope pushed!
    Wonderful to have all this stuff put in context showing the purpose.

Leave a Reply

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