Displaying random authors while excluding admin role
-
I’m trying to run a loop on my homepage where 3 random user profiles will be displayed. I found the following in the forums, which works almost exactly how I want: https://www.ads-software.com/support/topic/display-random-authors-on-homepage?replies=16
However, I’m not quite sure how I would edit this to exclude any user profiles that are set as the administrator role.
Any help from the community would be greatly appreciated. My code is as follows:
<?php $uid = $wpdb->get_col("SELECT ID FROM $wpdb->users WHERE user_status = 0"); shuffle($uid); array_rand($uid); for($someNumber = 1; $someNumber <= 3; $someNumber++) { $userID = $uid[$someNumber]; ?> <article> <h1><a href="<?php echo get_author_posts_url($userID); ?>" class="author"><?php the_author_meta( 'display_name', $userID ) ?></a></h1> <div class="postmeta"><a href="<?php echo get_author_posts_url($userID); ?>" class="author">View Author Bio</a></div> </article> <?php } unset($uid,$userID); ?>
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Displaying random authors while excluding admin role’ is closed to new replies.