Skip to content

Instantly share code, notes, and snippets.

@jitenbharadava
Created October 19, 2015 06:25
Show Gist options
  • Select an option

  • Save jitenbharadava/8cf700defeb7af6f0341 to your computer and use it in GitHub Desktop.

Select an option

Save jitenbharadava/8cf700defeb7af6f0341 to your computer and use it in GitHub Desktop.
Show Author wordpress
<?php
// prepare arguments
$args = array(
'role' => 'Author',
'orderby' => 'display_name', // Order by display name
//'exclude' => array( 2, 5, ), // Remove the two main admins
);
// Create the WP_User_Query object
$author_query = new WP_User_Query( $args );
// Get the results
$authors = $author_query->get_results();
// Output results
foreach( $authors as $author ):
$pattern = '<%1$s class="%2$s">%3$s</%1$s>';
echo '<li class="author author-' . $author->ID . ' author-' . $author->user_nicename . '">';
// printf( $pattern, 'div', 'author-gravatar', '<a href="' . get_author_posts_url( $author->ID ) . '">' . get_avatar( $author->user_email, 96, null, $author->display_name ) . '</a>' );
printf( $pattern, 'span', 'author-name', '<a href="' . get_author_posts_url( $author->ID ) . '">' . $author->display_name . '</a>' );
printf( $pattern, 'div', 'author-description', get_the_author_meta( 'user_description', $author->ID ) );
echo '</li>';
endforeach;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment