WordPress.org

Support

Support » Plugins and Hacks » How to paginate posts by date?

How to paginate posts by date?

  • 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….

  • The topic ‘How to paginate posts by date?’ is closed to new replies.
Skip to toolbar