Chronologically ordered blog in wordpress

May 14th, 2007

I recently started the FedDibblety house blog, documenting our home improvements to our new home in Indiana (which Clare’s parents built). I set up accounts for my wife Clare, her parents, Dave and Ellen, and my parents, Harold and Fran. Ellen, being a technology nut like myself, immediately jumped in writing posts about the house, and also had some feature requests. One of those features was to have the blog read in chronological order. Most blogs read in reverse chronological order, but since this one was kind of diary-esque, it seemed more appropriate to have it in normal order. I am also dating posts corresponding to the improvements made, not the actual post date. I started searching around for forum posts and such about how to do this, and I came across two relevant ones. I came across one post on wordpress.org which had a very simple solution, of simply adding one line to the index.php file in the root directory, like so:

<?php
/* Short and sweet */
define('WP_USE_THEMES', true);
$order = 'ASC'; //adding this line
require('./wp-blog-header.php');
?>

This did exactly as one would expect. However, this also caused some problems. For those avid blog readers, now they would have to scroll way down (or go the archives) to see new posts, which doesn’t really make sense. In addition, the RSS feed was also chronologically ordered, so that RSS users would find it very difficult to see if the blog had been updated recently. While searching I also found another post on janegalt.net, in which the blogger asked the same question, and a reply by Jeff Licquia suggested a very simple solution:

To set up archives to use a different template, go into the management page, then go to Options, then Permalinks.

If you can’t, or don’t understand, the RewriteRules stuff, look at the note about not being able to use mod_rewrite. Where it says:

/index.php/archives/%year%/%monthnum%/%day%/%postname%/

Change “index.php” to something else, like “archives.php”, and put that in for the virtual site structure. Copy index.php to archives.php in your document root, then add the special flag to archives.php. You should be all set at that point.

(I’m a newbie to WordPress, but not to Web servers or Web stuff in general, so the above makes sense to me but isn’t tested. I’ll try to help if you have problems.)

This idea worked very well. I made the change in the Wordpress options page, then copied index.php to archives.php, using the $order=ASC flag, and removed that from index.php. Then I had to change the .htaccess file to direct queries to archives.php. I did not want to do this for feeds though, so I had to put in two rules, like so:

#.htaccess file for fedibblety/house blog
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /house/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !.*feed\/?$ [NC]
RewriteRule . /house/archives.php
RewriteCond %{REQUEST_FILENAME} .*feed\/?$ [NC]
RewriteRule . /house/index.php
</IfModule>

Then there was one last thing. In that blog (and in this one), I am using the fancy-archives plugin (as I write this post that site seems to be down, so I am not providing a link), which I have tweaked a bit. To get the archives in the sidebar listed in chronological order, I just had to change the SQL queries in the fancy-archives-list.php file to ORDER BY post_date ASC.

That was it!

  • FriendFeed
  • Reddit
  • del.icio.us
  • Digg
  • Slashdot
  • Technorati
  • Facebook
  • Fark
  • TwitThis
  • LinkedIn

6 Responses to “Chronologically ordered blog in wordpress”

  1. On March 7th, 2008 at 8:56 am
    Tina Anderson wrote:

    Do you have the url for that fancy-archives plugin you mentioned yet? That sounds very interesting.

  2. On March 10th, 2008 at 8:52 am
    robfelty wrote:

    Tina,

    I have released an updated and improved version of the fancy-archives plugin which I now call “collapsing archives”. It is available on wordpress.org

    Thanks for reading.

    Rob

  3. On March 23rd, 2008 at 2:59 pm
    Sreedinesh wrote:

    Hey i want that url of the plugin that you have mentioned right away!
    http://sreedinesh.blogspot.com

  4. On May 8th, 2008 at 3:36 pm
    PSP Accessories wrote:

    Nice post. I’m also interestes in that plugin, can i have it too ….thanks

  5. On June 19th, 2008 at 5:08 pm
    Armour wrote:

    Will this plugin would be effective? Jus check out http://pluking.blogspot.com and help me!

  6. On October 26th, 2008 at 1:12 pm
    Data Storage wrote:

    - It’s always interesting to read about how one upgrades their home because sometimes, they not only blog the steps in a particular task, but actually put forth actual instruction so others may try it out as well.
    - Wordpress is really the best way to go about it in my book because they make it idiot-proof to set up a good-looking blog w/o making any major errors (if you follow the instructions to the tee)
    - I liked how you set up your archives in chronological order. I never bothered to do it on my blogs before, but I’m going to impliment it now with the code you graciously shared w/ is. Thanks!

Leave a Reply