Skip to content

Instantly share code, notes, and snippets.

@mrfoxtalbot
Created February 5, 2016 11:12
Show Gist options
  • Save mrfoxtalbot/e67c878cc90abad21705 to your computer and use it in GitHub Desktop.
Save mrfoxtalbot/e67c878cc90abad21705 to your computer and use it in GitHub Desktop.
twentyfourteen_list_authors () // http://hookr.io/functions/twentyfourteen_list_authors/
function twentyfourteen_list_authors() {
$contributor_ids = get_users( array(
'fields' => 'ID',
// 'orderby' => 'post_count', // WPCOM disabled, see #2023-wpcom-themes
'order' => 'DESC',
'who' => 'authors',
) );
foreach ( $contributor_ids as $contributor_id ) :
$post_count = count_user_posts( $contributor_id );
// Move on if user has not published a post (yet).
if ( ! $post_count ) {
continue;
}
?>
<div class="contributor">
<div class="contributor-info">
<div class="contributor-avatar"><?php echo get_avatar( $contributor_id, 132 ); ?></div>
<div class="contributor-summary">
<h2 class="contributor-name"><?php echo get_the_author_meta( 'display_name', $contributor_id ); ?></h2>
<p class="contributor-bio">
<?php echo get_the_author_meta( 'description', $contributor_id ); ?>
</p>
<a class="button contributor-posts-link" href="<?php echo esc_url( get_author_posts_url( $contributor_id ) ); ?>">
<?php printf( _n( '%d Article', '%d Articles', $post_count, 'twentyfourteen' ), $post_count ); ?>
</a>
</div><!-- .contributor-summary -->
</div><!-- .contributor-info -->
</div><!-- .contributor -->
<?php
endforeach;
}
// Y se llama así
if ( !function_exists( 'twentyfourteen_list_authors' ) ) { 
require_once '/functions.php'; 
}
// NOTICE! Understand what this does before running. 
$result = twentyfourteen_list_authors();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment