davidgagne.net

  • About
  • Archives
  • Twitter
  • Facebook
  • bartender.live
  • GitHub
  • LinkedIn

WordPress Wednesday: Displaying Older Posts

May 6th, 2008 @ 3:38 pm PDT

In which I explain a bit of MySQL

WordPress Wednesday: Displaying Older Posts

WordPressI’m suffering from a little bout of writer’s block these days. When you combine that with the fact that I haven’t been cruising the ‘net finding new and funny things, it makes for a dearth of new content on this site. I was thinking that it would be cool to display a single post from the archives at the top of the home page when there’s nothing new to see. Something like, “Hey! Sorry I haven’t posted anything new in x days, but check out this from y years ago …” I got as far as writing the SQL for it, but then I stopped working on it. I think it’s a good idea, though. Maybe someone will decide to write a plugin to do this. (Or, more likely, someone already has and I am just too lazy to find it.)


In case anyone is interested, here is the SQL to find a post written on “this day prior to today”:

select * from wp_posts where date_format(post_date, '%m/%d') = date_format(now(), '%m/%d') and date_format(post_date, '%Y') < date_format(now(), '%Y') and post_status = 'publish' and post_type = 'post' order by comment_count desc, id desc limit 1

The query sorts by the post with the most comments on the assumption that that is probably the most interesting post if there were multiple posts on that day.

More posts tagged:
archives / blogging / code / hacks / plugins / wordpress / wordpresswednesday

More posts categorized:
blogging blogtech

More posts from:
May 2008 / 2008

Post navigation

Previous Post
Previous Post Heading for Alaska
Next Post
Next Post Contextless Content: Episode #26 (David Bowie)

Search


If credit card debt or student loan payments are killing you, I highly recommend taking a look at SoFi. Their low rates and incredibly quick and simple application process might be just what you need.

  • Take Control of Your Debt

© David Vincent Gagne. All rights reserved. Custom WordPress Theme by Jacket Industries.