WordPress.org

Ready to get started?Download WordPress

Forums

display post date (2 posts)

  1. radiofranky
    Member
    Posted 2 years ago #

    hi,
    I would like on my main page to display post date and followed by posts of that date. Something like in those deals sites with date and follow by deals of that day.

    thanks

    7/12/12 <= how to I insert this in the template?
    1) post 1
    2) post 2
    3) post 3

    7/11/12
    1) post 1
    2) post 2

  2. vtxyzzy
    Member
    Posted 2 years ago #

    You need to keep track of the current date being displayed and show a new date when one is found. The WP function the_date() can be used to do what you want. Your code would be something like this:

    while (have_posts()) : the_post();
       the_date('F j,Y','<h2>','</h2>');
       // rest of Loop
    endwhile;

    This would show the date in <h2> tags each time a new date is found.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.