• Here’s what I want to do:
    List my posts by date (which is done by default), but then sub-order the posts published on the same date by category.

    So let’s say I have 10 posts in my DB; 5 are from April 1st and 5 are from April 2nd. The 5 posts from April 1st are from 5 different categories, the 4 posts from the 5th are from the same categories but were posted in a different order.

    Right now this is what I see on the blog:

    April 2nd, 2008
    Post 10 (cat id 3)
    Post 9 (cat id 5)
    Post 8 (cat id 2)
    Post 7 (cat id 4)
    Post 6 (cat id 1)

    April 1st, 2008
    Post 5 (cat id 1)
    Post 4 (cat id 3)
    Post 3 (cat id 4)
    Post 2 (cat id 2)
    Post 1 (cat id 5)

    But this is what I want:

    April 2nd, 2008
    Post 6 (cat id 1)
    Post 8 (cat id 2)
    Post 10 (cat id 3)
    Post 7 (cat id 4)
    Post 9 (cat id 5)

    April 1st, 2008
    Post 5 (cat id 1)
    Post 2 (cat id 2)
    Post 4 (cat id 3)
    Post 3 (cat id 4)
    Post 1 (cat id 5)

    Is there a way to sort and order the posts twice? Once by date, then by category by date?

    I’ve looked into the query_posts tag and can order all my posts by date and title, but the ‘category’ parameter has been gone since v 2.6; on top of that, is it even possible to order by two different parameters like I want to or will this call for a special query?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi

    You will need a custom SQL query. Also, take into account if there is any possibility of an post ever being in more then one category (WP allows that) as then you either have to choose which cat to order the post by, or have it appear more than once.

    Thread Starter jimsanders9

    (@jimsanders9)

    Thanks for your reply!
    I’ll try to get in touch with a coder who can author such a query.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Ordering posts by date, category’ is closed to new replies.