尝试按名字的字母顺序对 WordPress 用户进行排序。标准 WP_User_query 不起作用,因为我需要组合三个不同的用户角色,如您所见。关于如何按用户名的字母顺序对该列表进行排序的任何想法?我不知道该怎么办!
<?php
// get the featured editors
$editor_query = new WP_User_Query( array( 'role' => 'Editor' ) );
$editors = $editor_query->get_results();
// get the featured authors
$author_query = new WP_User_Query( array( 'role' => 'Author' ) );
$authors = $author_query->get_results();
// get the featured managers
$manager_query = new WP_User_Query( array( 'role' => 'Manager' ) );
$managers = $manager_query->get_results();
// store them all as users
$user_query = array_merge( $authors, $editors, $managers );
// User Loop
if ( !empty( $user_query ) ) {
$sortArray = array();
foreach ( $user_query as $user ) {
$auth_id = get_userdata($user->ID);
$job_title = get_the_author_meta( 'job_title', $user->ID );
$avatar = get_avatar($user->ID, 87);
$post_count = get_usernumposts($user->ID);
$author_profile_url = get_author_posts_url($user->ID);
?>
<div class="wp-author-wrap">
<div class="wp-team-box">
<a href="<?php echo $author_profile_url; ?>"><?php echo $avatar; ?></a>
<a href="<?php echo $author_profile_url; ?>" class="wp-author-title"><?php echo get_user_meta( $user->ID, 'first_name', TRUE ) . ' ' . get_user_meta( $user->ID, 'last_name', TRUE ); ?></a>
<?php echo $job_title; ?>
<ul>
<li><a href="<?php echo $author_profile_url; ?>">View <?php echo get_user_meta( $user->ID, 'first_name', TRUE ); ?>'s Profile</a></li>
<li><a href="<?php bloginfo( 'url' ); ?>/?s=+&author=<?php echo $user->ID; ?>">Read <?php echo get_user_meta( $user->ID, 'first_name', TRUE ); ?>'s Posts</a></li>
</ul>
</div>
<div class="wp-dots"></div>
</div>
<?php }
} ?>
多谢你们!