Monday 6th February 2012

Reverse Blogging

by Dave on December 9, 2009

Was just adding ‘Pro’s and Con’s’ to my review site christmastips . As I added the Pro’s comment I realised that it was going to be above my first post, which had all the intro to the product stuff on it. Hence I had to reverse the chronology of the posts, so that the first one would always be first.

It took me about 30mins of research and trying things out before I got something that worked. The initial answers I found told me to insert a line of code before the iteration of checking the posts.  Could not get that to work at all, threw all kinds of errors from echoing the code on the main website, to parsing errors, to not working at all. Also tried widgets that were supposed to do this ..to no avail

Eventually I replaced the

(This is where a line of reverse chronology code should’ve gone)

<?php if (have_posts()) : ?>

(I Tried it here too..)

<?php while (have_posts()) : the_post(); ?>

<div <?php post_class() ?> id=”post-<?php the_ID(); ?>”>

With

<?php query_posts($query_string.’&posts_per_page=5′.”&order=ASC”);if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>

and it worked just fine and dandy. Of course I did take back up measures when I did this, as one should always do.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • MisterWong
  • Y!GG
  • Webnews
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit

Leave a Comment

Previous post:

Next post: