LazyWeb Request: Date-Based Theme Switcher for WordPress

Jason Santa Maria said something in his last post about art directing blog entries that struck a chord with me:

“I am a huge proponent of preservation on the web. If and when I redesign, I will archive this version like I did with my last. I think it’s important to keep content and design paired together when possible. That’s where the context and meaning live.”

I agree with Jason and his reasoning is part of why I haven’t redesigned Mike Industries since launching it almost five years ago: I don’t like the idea of changing the visual context of past entries or having to make a new design backwards-compatible, especially with with some of the more visually complex entries that have appeared from time to time.

While I like Jason’s idea of archiving entire versions of his old sites at different subdomains, I think I’d actually rather just set a cut-off date whereby every blog post older than that date uses the old theme and every other page or post on the site uses a new theme. In searching around, I can’t find a way to do this in WordPress. It seems like something that could be the basis for a very useful plug-in. Call it “WP Non-Destructive Redesign” maybe.

Any WordPress hotshots out there know how something like this could be accomplished? For the quick and dirty version, ideally you’d first officially switch to a new theme and then there would be one setting in the plug-in’s options which would let you specify a cut-off date and a theme name to apply to the old stuff.

Like this entry? You probably shouldn't follow me on Twitter here. I recommend the RSS feed instead.

20 Responses:

  1. I think what you need is a meta-theme. This theme saves options which get checked on page call and “route” various requests to the various themes, assuring that the appropriate theme actually exists. There’s a question in the forums about using more than one theme for a site, with no satisfactory answers other than to use different templates per page/area.

    I’ve done some theme hacking, but this is beyond my experience.

    I’d be interested to hear from more experienced folks on this.

  2. I’d pay for a plugin like this. Thanks for putting it out there Mike.

  3. I think I would try to do it by dyanmically adding an ID to the body based on the posts date. For example, if the posts date was prior to the redesign date, add “olddesign” as the ID value on the body. This will give you a css hook to restyle anything on the page as needed.

    Not very efficient though, as all pages would be loading css information for both designs. A plugin that just could swap themes would be better. I’ve seen one that delivered different themes depending on if a user was logged in or not – so it seems like it can be done.

  4. I usually find your posts some of the most profound about web design and site management on the entire web. But I disagree with you on this one.

    I just got done writing my own blogging engine from scratch because I wasn’t happy with WordPress or B2Evolution, etc… Next stop, redesigning the whole site visually.

    But the last thing I would want is to have different designs on my site. Sure the uniformity takes some time…and I too have had some pretty visually complex posts, but it’s worth it.

    Maybe it is my “German-ness”, but once you land on a site, I think the design should be uniform through out the site.

  5. Mike D. says:

    chris: That’s a good idea. The major limitation would be that you could only change the CSS stuff though… not the template stuff. I will probably want to change PHP, HTML, and a bunch of other stuff in a new theme. Good idea though.

    Andy: I don’t really disagree much with that, but for me, a blog is a reflection of things over time. As opposed to a “site”, which is more like a reflection of the current state of things. In other words, when you redesign a non-blog site, you want everything current. Anything old-looking is bad. But with a blog, I really don’t want a blog entry I wrote in 2004 to look like one I wrote in 2008, if things in design and things in my life have changed since then. I also don’t think there would be a whole lot of “jumping around from old to new” when a visitor visits a blog which split its design up as I’m suggesting. Normally, people either visit a single page because it was linked to from somewhere (or in a search engine), or they read mostly newer posts because they are subscribed.

  6. Martin says:

    A simple search and I found this:
    http://wordpress.org/extend/plugins/nkthemeswitch/

    It should be VERY simple to change.

    Just replace
    if(current_user_can(get_option(‘nkthemeswitch_level’))) {
    With a check for postdate..

  7. Mike D. says:

    Martin: Whoa, that might be the perfect tool for the job. I even like its current functionality, because with it, you could develop a new theme that only you would see, and then when you’re ready to flip it live, you could use the proposed added functionality to apply the theme only to new posts.

    Very interesting.

    I think I’m going to either contact Nicolas and see if he wants to add that functionality in officially, or maybe I’ll just hack it in myself and send it to him. Thanks!

  8. Although I see your point and agree with the visual context arguement , I think I have to disagree with this based on the following premise:

    If a new reader landed on your homepage and saw version #3 of your site, they will sub-consciously indexed the branding to your site. Now let us say that they click a link in your Recent Entries section and the page that is served is styled as was in version #1 or version #2 of your site. This will be very misleading to a new reader, as there is inconsistency with your brand or your online identity.

    . Site design is an all or nothing thing. I would advocate looking at your current content and make design decisions early based on that. Of course this is a harder approach

  9. Mike D. says:

    Daniel: This is a valid point, however, after about ten new entries in the new format, that consideration is greatly lessened (because the last ten entries will have the new design).

    I think a lot of this decision comes down to “how much do you like/hate your current design”? In a lot of redesigns, the designer has grown to hate the old design (or he’s working with someone else’s design so he already hates it). If this was the case for me, I might feel differently. But I actually like my current design still. Its shine has dulled a bit, but I can’t say it bothers me at all. The redesign would be more about adding functionality and better separating out different types of content. It’s driven a lot by the fact that these days I like to publish a lot of things that aren’t really design or code related and I want a site that lets me publish all sorts of content without subjecting everybody to it who may only be interested in the design/code stuff.

  10. milo says:

    Another idea might be a php based style switcher,
    then based one the parameters modifying the “if cause” to change the CSS stylesheet according to years, months, weeks or whatever you like.

  11. roj says:

    Mike, at a quick glance it should be fairly straightforward to set up a plugin to assign themes to particular date ranges and both examples above could be used.

    Problems might be introduced through the central options set in the admin panel (settings & widgets included). Not a huge problem depending on how different the design will be. Also, you could quickly get round these by hard coding most of them into the theme files anyway.

  12. roj says:

    On further thought there’s probably a quicker way.

    As I assume keeping the old design will be solely for individual pages you could set up a conditional in your single.php where before the cut-off date you load say old_design.php. In that file you then have the full page code (ie no separation of headers, footers and sidebars) and also have it calling the old_design.css.

    It’d be quicker to get up and running than all the hassle of creating a plugin given that you have template sitting ready to go & just need to do a little copy & pasting exercise + a single php conditional.

  13. Chris says:

    Mike, I frequently update/refine the look of my blog but the content has changed over time. Earlier posts tended to be design related and often just silly/fun. More recently they have been about my landscape and wildlife photography. But I understand your dilemma.

  14. Martin says:

    Ok, it wasn’t as simple as I would have hoped. I took a shot at modifying http://wordpress.org/extend/plugins/nkthemeswitch/ and ran into a problem.
    The theme is choosen before wordpress knows what post it’s going to show.

    Seems like the easiest approch is to use templates..
    http://codex.wordpress.org/Tag_Templates
    And tag all old post with “old” or something like that..

  15. roj says:

    So I forgot that you don’t have the post date until you fetch it from the db so the basic single.php file might look like this:

    // Define the cutoff date (Format: YYYYMMDD)
    $cutoff_date = 20070517;

    if ( have_posts() ) :
    while ( have_posts() ) : the_post();
    $old = (get_the_time(‘Ymd’) > $cutoff_date) ? TRUE : FALSE;
    endwhile;
    endif;

    if ($old === TRUE)
    {
    include(TEMPLATEPATH . ‘old_design.php’);
    // Where old_design.php is the complete template for a single old design page
    }
    else
    {
    // Put your new design for single pages here
    }

    This obviously adds new queries into the process which a plugin might avoid but it’s quick and dirty and, on quick testing, appears to work. You could also refine the loop to be a single query.

    Hope it helps.

  16. Mark says:

    Tag Templates are for Tag “Index Pages” rather than a post with a tag associated to it:
    http://codex.wordpress.org/Tag_Templates

    I quite like the subdomain idea really. With that system you could replace all of the links to a certain age of content with a subdomain’d link, offering a link to your most recent design as the same url without the subdomain attached.

  17. roj says:

    For anyone who’s interested: I’ve quickly thrown my idea into a plugin which let’s you set a single cut-off date and old template file. It also uses the plugin hooks so saves on the additional loop / db queries.

    You can find it under old wordpress designs on my site.

  18. I’m not even sure why you’re bothering with this. Your new design will just be a single, drop-shadowed column with a new color palette. But maybe you’ll reverse out some type and put the auxiliary column on the left to “shake things up.”

    (Editor’s Note: Bitch.)

  19. Thanks for your comment roj! I was looking at a fairly unrelated issues, but needed a conditional before/after date scenario. Your code helped heaps!

    In terms of keeping design and content together. I’m not so fussed when it comes to my blog (probably ’cause it’s a personal blog that will change as I do), but if I were I would go with a conditional stylesheet. A few times when I’ve changed infrastructure I’ve actually done a search and replace in my database to make class names etc match up with the new ones, rather than continue to maintain deprecated CSS. It was pretty quick and I find it reassuring that my database is up to date as well.

  20. [...] I wanted to find a way to keep old blog posts in the old theme and style new blog posts with the new theme. I like this idea because it preserves the context in which posts were originally written and it [...]

Leave a Reply

Shared

Hundreds of headlines wash over us every day. And part of why many of us engage in this flow is because we have faith that over time, this torrent of episodic knowledge is going to cohere into something more significant: a framework for genuinely understanding an issue. And we live with it ’cause it sort of works. Eventually you hear enough buzzwords like “single-payer” and “public option” and you start to feel like you can play along.

But mounting evidence indicates that this approach to information is actually totally debilitating. Faced with a flood of headlines on an ever-increasing variety of topics, we shut off. We turn to news that doesn’t require much understanding – crime, traffic, weather – or we turn off the news altogether.

- Matt Thompson on why the way we report and consume news is precisely wrong. Matt is, of course, precisely right. If you’re at SXSW next week, I don’t know how you could justify missing this talk.

Cameron’s Colosseo letterpress poster is now available: The only question is, black or white? The black is oh so tempting!

Jon Stewart Skewers Media’s Obsession with Chat Roulette: Funniest Wii Craps reference ever, as well. It’s really interesting to me that Chat Roulette is getting this much “attention” when TinyChat has been around so much longer, essentially does the same thing and more, and is much more useful to the average person. Just goes to show how viral public sex acts can be.

"Add features and customers forever and rake in the dough.":

The 2005 email that spawned Picnik, Google’s latest buy. If you’re thinking about launching a startup, you should study this e-mail carefully. It’s a perfect example of exactly how a crazy little thought becomes a big idea, and even on its own, it’s better than most “official company business plans” people present to VCs.  I gave a talk at Webstock in New Zealand a couple of weeks ago about creating a startup and I wish I had this to dissect at the time. Really good stuff.

Tumblr Finally Rolls Out Comments. Sort Of. Trolls Not Welcome. :

I actually really like how clubby it is.  Unfortunately it means I won’t be commenting on any Tumblrs since I don’t officially “follow” anyone besides via RSS, but that’s probably ok. Maybe the answer to the world’s wide-open commenting problem is something like this.

Episode 2 of Dan Benjamin's "The Conversation" is Live:

I was a guest on Dan Benjamin’s new weekly radio show last week, along with Merlin Mann, Christina Warren, Adam Keys, and Dave Nanian. Subjects discussed include Newsvine, keeping your own identity after becoming part of a big company, and the RADICAL concept of only publishing stuff to your readers and followers that is actually true.

LESS - Leaner CSS:

Given that pre-compiling CSS is an official “best practice” these days, why not use that compile step to extend CSS in powerful ways? LESS lets you use variables, nested rules, and other niceties at author-time to clean up your rules and keep everything tidy. I believe The Wolf made something like this a few years ago, but I haven’t heard about it since.

How 3D works, and why it's back:

Great article on the ins and outs of three dimensional imagery. Still doesn’t change my opinion that well-shot conventional cinematography is more impressive than the novelty that is Avatar.

The Importance of Removing Features:

This is one of the most useful articles I’ve read in a long time. As we work on focusing, strengthening, and simplifying Newsvine, the concepts discussed by Lukas ring true. “Saying no” has never been a strong suit of mine. It’s very helpful to remember how important of a quality it is. (via fullstopinteractive)

Newly released video of the space shuttle Challenger disaster: It was 24 years ago, I was in 5th grade, but I remember it like it was yesterday. School was stopped immediately and they wheeled out televisions in every classroom for us to watch the news footage. It’s great that this video has been released, but holy crap, how do you tuck something that away for two decades???

A nicely done british parody of 60 Minutes style video journalism. It’s easy to miss how formulaic our news is sometimes. (via B-Tizzle, originally via E-Chizzle)

Colosseo: This is why Cameron is a king and we are all just pawns in his world. I can’t wait to get my hands on this poster. I will point out, however, that the outro credits on the video need some kerning. Someone is going to lose their right hand for that.

Spezify:

New ways of searching are almost never as useful as old ways of searching. Spezify is pretty awesome though. It’s a visually interesting, never-ending, horizontally and vertically scrollable, topic explorer. I don’t think I’d use it for digging deep on anything, but to get a quick visually rich sampling of a topic, it’s quite fun (via tiff, a long time ago actually, over email).

Realism in UI Design:

Reminds me of my favorite logo design advice: “Never waste a stroke”. (via gruber)

Overshared
At the first Doughty show of the night at the Triple Door. If you're in Seattle you should come down for the 2nd at 10. Excellent!
This Kindle ad is cute and Applelike but misses the mark. Advertise what you do well: price and battery life http://bit.ly/cFBw70
@codinghorror Aliased Monaco 9 should be in the Smithsonian.
Why does the media continue to cover what Rob Glaser thinks about the future?
@Trenti Ummm, the Timex Sinclair came out after the VIC-20, beeeeeeeayatch! I will out-old you any day!
@paulsmith Wow. I love the user manual shooting out from Shatner's shoulder at the perfect angle. http://j.mp/am10eU
@paulsmith You have me beat by mere months there! I cut my teeth on a Practical Peripherals 1200 bauder.
@roblifford Probably a 10% chance I fly in at the last minute for a couple of nights. Other than that, planning to skip this year.
I can't believe @shauninman's first computer was a G4. I feel ancient. Mine was a VIC-20. http://5by5.tv/pipeline/5
Wow, how did I not know about Lala until now? Tons of great full albums, free: http://bit.ly/dBrdLw
Thanks for everyone who suggested Brizzly. Going to fire that sucker up again...
Is there a way to unfollow people but still allow them to DM you? Like a "mute" setting or something?
@levifig Burn-in was a bigger issue with first-gen plasmas. They are much better now. LCDs have their own lighting issues as well.
@horsedreamer The black isn't quite as good as some other top plasmas, but it's better than all LCDs. At an inch thick, I'll take it.
@levifig Isn't ghosting mainly an issue for LCDs? I've had a plasma for four years and no ghosting whatsoever.