Skip to content

Instantly share code, notes, and snippets.

@platoosom
Created April 14, 2020 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save platoosom/483d318410bc57b227dc11d9f9c589c1 to your computer and use it in GitHub Desktop.
Save platoosom/483d318410bc57b227dc11d9f9c589c1 to your computer and use it in GitHub Desktop.
Wordpress get user by role
<div class="container mt-100">
<h1 class="title text-center mb-40">Featured Guests</h1>
<div class="row">
<div class="col-sm-4 col-6">
<div class="item-advisory">
<?php
$args = array(
'role' => 'featured_guest',
'orderby' => 'user_nicename',
'order' => 'ASC'
);
$users = get_users( $args );
foreach ($users as $user){
?>
<div class="item-advisory__image mb-20">
<?php echo get_avatar($user->ID, 255); ?>
</div>
<div class="item-advisory__details">
<a href="#" target="_blank">
<h1 class="text-subtitle font-dm"><?php echo $user->display_name; ?></h1>
</a>
<p class="txt-body text-color-grey"><?php echo get_user_meta($user->ID, 'position', true); ?></p>
<div class="social-media mt-10">
<?php if(get_user_meta($user->ID, 'linkedin', true)){?>
<div class="item">
<a href="<?php echo get_user_meta($user->ID, 'linkedin', true); ?>>"><i class="fab fa-linkedin-in"></i></a>
</div>
<?php }?>
<?php if(get_user_meta($user->ID, 'twitter', true)){?>
<div class="item">
<a href="<?php echo get_user_meta($user->ID, 'twitter', true); ?>>"><i class="fab fa-twitter"></i></a>
</div>
<?php }?>
<?php if($user->user_url){?>
<div class="item">
<a href="<?php echo $user->user_url; ?>>"><i class="fas fa-globe"></i></a>
</div>
<?php }?>
</div>
</div>
<?php
}
?>
</div>
</div><!-- .col-->
</div><!-- .row-->
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment