Ready to get started?Download WordPress


WP_Query orderby author specify secondary orderby criteria (3 posts)

  1. adambundy
    Posted 1 year ago #

    Dealt with an issue today where I was querying for all post of a given post type, then ordering them by author. I figured out after some investigating that by default, within each author's posts, WP_Query orders those posts by their modified date. Is there some way to specify a secondary criteria without having nested queries, one first for authors, then looping on each author's posts? In my case, I wanted to order the posts by author, but then within each author, order them by ID.


  2. esmi
    Forum Moderator
    Posted 1 year ago #

    WP_Query orders those posts by their modified date.

    Are you sure about that? I thought the default ordering was by post ID - which usually means by creation date.

  3. adambundy
    Posted 1 year ago #

    @esmi, you're right - after further examination, I think that it orders the posts within a particular author's posts neither by created date, modified date, or post ID. I am still digging but currently have no idea which criteria WP uses to order these posts. Anyone have any knowledge in this?


Topic Closed

This topic has been closed to new replies.

About this Topic