Created
October 10, 2014 09:24
-
-
Save jb510/f6ea0073b2dc18a79640 to your computer and use it in GitHub Desktop.
Genesis list users by role
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Template Name: Page Contributors | |
*/ | |
remove_action('genesis_loop','genesis_do_loop'); | |
add_action('genesis_loop','jb_contibutors'); | |
function jb_contibutors() { | |
echo '<ul>'; | |
//jb_contibutor_loop(array( 'role' => 'administrator', 'fields' => 'all_with_meta' ) ); | |
jb_contibutor_loop(array( 'role' => 'editor', 'fields' => 'all_with_meta' ) ); | |
jb_contibutor_loop(array( 'role' => 'author', 'fields' => 'all_with_meta' ) ); | |
jb_contibutor_loop(array( 'role' => 'contributor', 'fields' => 'all_with_meta' ) ); | |
echo '</ul>'; | |
} | |
// Get the results | |
function jb_contibutor_loop($role) { | |
// Create the WP_User_Query object | |
$wp_user_query = new WP_User_Query( $role); | |
$users = $wp_user_query->get_results(); | |
// Check for results | |
if (!empty($users)) { | |
// loop trough each author | |
foreach ($users as $user) { | |
// get all the user's data | |
$user_info = get_userdata($user->ID); | |
$img = get_avatar($user_info->ID, 150); | |
$url = site_url('/author/'); | |
echo '<li class="aap_user_wrap"><a href="' . $url . $user_info->user_nicename . '">'; | |
echo '<span class="aap_user_name" property=\"v:name\">' . $user_info->first_name . ' ' . $user_info->last_name . '</span>'; | |
echo '<span class="aap_user_img">' . $img . '</span>'; | |
echo '</a></li>'; | |
} | |
}; | |
}; | |
genesis(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment