WordPress.org

Ready to get started?Download WordPress

Forums

How to paginate posts by date? (1 post)

  1. mrgreyisyelling
    Member
    Posted 4 years ago #

    Goal: To display all posts create on same day on a single page, AND navigate back and forth.

    Currently I'm using this very sloppy method:

    while (!have_posts() && $i < 4000) :
    		$i++;
    		$yesterday = date('d', mktime(0, 0, 0, date("m") , date("d") - $i, date("Y")));
    		$yesteryear = date('Y', mktime(0, 0, 0, date("m") , date("d") - $i, date("Y")));
    		$yestermonth = date('m', mktime(0, 0, 0, date("m") , date("d") - $i, date("Y")));
    		query_posts('year=' .$yesteryear .'&monthnum=' .$yestermonth .'&day=' .$yesterday.'&order=ASC' );
       endwhile;

    And am passing $i between pages using $_GET.

    As you can see, I'm newish with wordpress.

    Example:
    page 1 - 2010-3-18: 10 posts
    page 2 - 2010-2-14: 5 posts
    page 3 - 2010-2-02: 1 post....

Topic Closed

This topic has been closed to new replies.

About this Topic