This is like one of those things where by the time you find a solution to a problem it has already fixed itself (see also, rebooting). And it hardly merits a blog post, but heck, I can write about what I want to write about. If you’ve been around the blog a while, you might […]
Last January, Tim Owens did a masterful job of assembling the Daily Create site out of a premium theme (Salutation), a mix of plugins (including Awesome Flickr Gallery, Tubepress, and Gravity Forms), etc– and no custom code.
When I arrived at UMW in February, I offered to take over the creation of the challenges. It is a mix of ones submitted by our site users, borrowed ones from the Daily Shoot, b3ta Challenges, the Vancouver Draw Down, and the 30 Day Drawing Challenge, plus about a good 30% we just dreamed up.
Creating them turned out to be a bit tedious as there was at least 7 different things to set on the interface. We had to have them, scheduled in advance, each to be published at 10:00 am EST.
(1) The title would be present if it was submitted via a form; for one from scratch it is entered/pasted.
(2) The post name was manually entered, based on the tag for the day
(3) Depending on the type of Daily Create, we had a format for the post that would use a set of links to flickr, you tube tags to set up the instructions, and for the embedding of media, a Tubepress shortcode, flickr gallery ID, or a SoundCLoud embed code. For these, the tag had to be manually entered in at least two spots. For the flickr ones, we would have to create an Awesome flickr gallery (another admin page), and manually copy/paste the shortcode. I started by copying from old posts (and managing a few times to edit the wrong one) and later kept a generalized version in a text doc for cutting/pasting
(4) The future date for publishing was manually set (10:00am EST)
(5) Two categories assigned for the type, and an overall category we use to group all assignments.
(6) The tag is entered here
(7) The theme required a selection menu to match it to the type of assignment (each type has its own graphic which is displayed in the single post view.
I did this for about two months before rolling up my elbows to see if this could be streamlined.
Each of the four types (Audio, Video, Photography, Drawing) have a different content structure which is what embeds the creative works in a post. When I looked it at, once the type was set and the tag as known (the tag tdc123 is also the slug for the post), it was potentially template-able.
I looked to see if there were any plugins for setting up at least the templates for the content, but did not find any that allowed for multiple templates.
But ti was looking at the admin interface for this very theme (the theme options down the right sidebar) that it dawned on me that I could possibly create my own box with a drop down menu to select a type, and when saved, the post would automagically fill in the right content and check the right boxes, etc.
So after completing the Daily Creates for 6 months in advance, doing this seriously paid off. I was typically able to knock off a months worth in about 90 minutes, and more of that was having to look around or make up assignments.
The way is works now is for a new post or if I edit something that is a draft, the TDC Settings meta box is activated.
(Gulp, note in this fake example, it should be a Drawing type, not photography, this assignment is not reallly in the mix… yet)
The only thing it needs is (1) the title, (the code automatically creates the next tag it should use based on the last one created) and (2) I just select the type from the drop down menu, and click Save Draft.
When saved, everything else is done for me!
(1) Tag is used for the url
(2) The basic content is created according to the kind of assignment, and the tag is inserted where it is needed. The * is because the automation is not 100% complete; I still have to generate the flickr gallery shortcode for Photography and Drawing types (I did experiment with calling the code directly; it was close but not quite correct). Also, the embed codes for SoundCloud are random IDs, not related to the group name, so that code is also manual.
(3) The future publication date is automatically set! This saves a ton of time. It simply looks for the last one created, and then sets the publication date for 24 hours later.
(4) Categories automatically checked
(5) (6) The tags and the header setting for the template are auto selected.
This is all done by some custom code to intercept the hook when a draft is saved, and then updating the post data (and some post metadata).
Below is the semi hairy code… broken into parts for explanation. This all lives in the functions.php part of the theme template (which truly should be done as a child theme). If I were more clever, I would have made it a plugin, but the code would be the same (One day I want to be 0.01% as code clever as Boone Gorges).
Here we go… code below the fold…
cc licensed flickr photo shared by QualityFrog In a previous long winding post, Dressing up and Displaying WordPress 3 Custom Post Content (a), I tried to document the first part of my WordPress 3 site I manipulated the new Custom Content types. It seems it takes longer to explain that to build, and in the […]