Support » Fixing WordPress » WP_Query orderby author specify secondary orderby criteria

  • adambundy

    (@adambundy)


    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.

    Thanks!!

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

    (@esmi)

    Forum Moderator

    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.

    adambundy

    (@adambundy)

    @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?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WP_Query orderby author specify secondary orderby criteria’ is closed to new replies.