You are viewing an old revision of this post, from March 17, 2014 @ 13:10:09. See below for differences between this version and the current revision.

Query Posts Ordered By Author Last Name

This is untried and taken from Stack Exchange: http://stackoverflow.com/a/22056861/2821561 [php] <pre><code>$args = array('posts_per_page' => '-1','order' => 'ASC', 'orderby' => 'author'); $cat_posts = get_posts($args); $options = array(); foreach ($cat_posts as $cat_post) : if (!in_array($cat_post->post_author,$author_array)) { $author_array[] = $cat_post->post_author; } endforeach; foreach ($author_array as $author) : $auth = get_userdata($author)->display_name; $nicename = get_userdata($author)->user_nicename; $lastname = get_userdata($author)->last_name; $options[ $lastname ][] = '<option value="/author/'.$nicename.'">' . $auth . '</option>'; endforeach; ksort($options); foreach ($options as $key => $option) { foreach( $option as $k => $v ){ echo $v; } }</code></pre> [/php]

Revisions

Revision Differences

There are no differences between the March 17, 2014 @ 13:10:09 revision and the current revision. (Maybe only post meta information was changed.)

Tags: ,

No comments yet.

Leave a Reply