Created
July 3, 2014 02:41
-
-
Save jdaviescoates/9e2633c302ee79650dc6 to your computer and use it in GitHub Desktop.
Code for adding contributor page
This file contains hidden or 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
/** | |
* Code for adding contributor page. | |
*/ | |
if ( ! function_exists( 'contributors_author_list' ) ) : | |
/** | |
* Prints author contributors. | |
*/ | |
function contributors_author_list() { | |
$contributor_ids = get_users( array( | |
'fields' => 'ID', | |
'orderby' => 'post_count', | |
'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="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; | |
} | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment