I have a post type called 'article' and on the article archive page i'd like to show all the articles, sorted by author.

function kia_adjust_the_query( $query ) {

    // change posts_per_page param
    if ( is_post_type_archive( 'article' ) ) {

add_action('pre_get_posts', 'kia_adjust_the_query');

the above sets up the basic query adjustments. however, the blog is principally that of 1 author, say "Bob"... so ideally i'd like to pull all of the posts by Bob out into a first column for emphasis, and then continue on through the other authors.

is this possible to do during the while loop somehow or do i need 2 separate queries?

//EDIT for added complexity: i usually try to strip my questions down to the minimum, but in this case i think i went too far

my client is the sole author on his blog. however, he uses a meta field ('guest_author') and filters get_the_author to create a pen name for guest posts that he didn't actually write, without creating accounts for other users.

can i sort the author posts that are his posts (so no value in the meta field) and then, by the other authors (same author ID, but different 'guest_author' values). if this isn't possible, would the best way to approximate it be to create dummy accounts for the other authors?

1 Answer 1


You could do that with a custom posts_orderby:

add_filter( 'posts_orderby', 'wpa58715_posts_orderby' );

function wpa58715_posts_orderby( $orderby_statement ) {
    if ( is_post_type_archive( 'article' ) ) {
        global $wpdb;
        $orderby_statement = "FIELD($wpdb->posts.post_author, 42) DESC, $wpdb->posts.post_author";
        return $orderby_statement;

Swap in your author ID for 42.

  • is there anyway to run this based on author name and not ID? or course my client would have to be difficult and and use pen-names for guest authors (stored in post meta) instead of creating other user IDs. otherwise, this does answer the question as i described it. Jul 17, 2012 at 1:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.