• Hi, I want to group my articles on the main page by date. I want something like this:

    12/04/07
    Post 1
    Post 1 text
    Post 2
    Post 2 text
    11/04/07
    Post 3
    Post 3 text
    10/04/07
    Post 4
    Post 4 text
    Post 5
    Post 5 text

    I saw this feature in some weblogs, and i don’t know if it’s a plugin, or it’s a wordpress setting.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Something like this might work if you’re not afraid of PHP:

    Look in your template’s index.php (or whatever template file controls your blog’s front page) for this:
    the_time(...)

    (It won’t really say “…”). Change this to say something like this:
    $currenttime = get_the_time(...)

    (Don’t change the “…” part). Then, right after (before any html or anything), paste in something like this:

    <?php if ( $currenttime != $lasttime ){
         print $currenttime;
         $lasttime = $currenttime;
    }  ?>

    I haven’t tried it, but unless I’m overlooking something, that should probably work.

    I don’t think you need any of the complicated code above. Just switch to the Classic theme – it will do exactly what you described. Study the index.php in that theme and you are good to go.

    Very true. Thanks for pointing that out rudolf45. Now that I look at the Classic theme, I see that I wasn’t aware of an easier way to do this.

    aditza121, if you don’t want to switch to classic, here’s an easier way to do it than what I wrote.

    Once again, begin by finding the_time(...). But just replace it with the_date(...). Only you need to make a slight modification.

    If the_time was between <h2> and </h2>, you would need to delete these and bring them inside the_date(), like this:

    the_date('', '<h2>', '</h2>')

    That will do it for you.

    Thread Starter aditza121

    (@aditza121)

    Thanks guys!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Group articles by date in main page’ is closed to new replies.