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.

20 comments on “LazyWeb Request: Date-Based Theme Switcher for WordPress”. Leave your own?
  1. Joe Crawford says:

    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. Sameer Vasta says:

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

  3. chris coyier says:

    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:

    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 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..
    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;

    if ($old === TRUE)
    include(TEMPLATEPATH . ‘old_design.php’);
    // Where old_design.php is the complete template for a single old design page
    // 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:

    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. Sean Madden says:

    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. kristarella says:

    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

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

Subscribe by Email

... or use RSS