I've looked far and wide and found nothing about this. I'm wondering if it's possible to sort/arrange all the front end comments, in an un-nested comment by comment author?

1 Answer 1


If you mean the comments in comments_template() then you can use the new comments_template_query_args filter that was added with ticket #34442 in version 4.5:

 * Filters the arguments used to query comments in comments_template().
 * @since 4.5.0
 * @see WP_Comment_Query::__construct()
 * @param array $comment_args {
 *     Array of WP_Comment_Query arguments.
 *     @type string|array $orderby                   Field(s) to order by.
 *     @type string       $order                     Order of results. Accepts 'ASC' or 'DESC'.
 *     @type string       $status                    Comment status.
 *     @type array        $include_unapproved        Array of IDs or email addresses whose unapproved comments
 *                                                   will be included in results.
 *     @type int          $post_id                   ID of the post.
 *     @type bool         $no_found_rows             Whether to refrain from querying for found rows.
 *     @type bool         $update_comment_meta_cache Whether to prime cache for comment meta.
 *     @type bool|string  $hierarchical              Whether to query for comments hierarchically.
 *     @type int          $offset                    Comment offset.
 *     @type int          $number                    Number of comments to fetch.
 * }
$comment_args = apply_filters( 'comments_template_query_args', $comment_args );
$comment_query = new WP_Comment_Query( $comment_args );


Here's an example where we target non-threaded comments:

 * Order non-threaded comments by comment author, in the (main) comments template
add_filter( 'comments_template_query_args', function( $comment_args )
    // Ignore threaded comments
    if(    isset( $comment_args['hierarchical'] ) 
        && 'threaded' === $comment_args['hierarchical'] 
        return $comment_args;

    // Our modifications
    $comment_args['orderby'] = 'comment_author';        
    $comment_args['order']   = 'ASC';

    return $comment_args;
} );

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.