<?php
/**
 * Template Name: Author Page
 *
 * @package WordPress
 * @subpackage Twenty_Fourteen
 */

get_header(); ?>

	<div id="primary" class="content-area">
		<div id="content" class="site-content full-width" role="main">
			<?php
			while ( have_posts() ) : the_post(); ?>

				<?php get_template_part( 'content', 'page' ); ?>

				<?php 
				$author_args = array(
					'orderby' => 'post_count',
					'who' => 'author'
				);
				$authors = get_users( $author_args );

				foreach ( $authors as $author ) {
					$post_count = count_user_posts( $author->data->ID );
					
					if( $post_count == 0 ) {
						continue;
					}

					$name = $author->data->display_name;
					$author_avatar =  get_avatar( $author->data->ID, $size = '128' );
					$bio = get_the_author_meta( 'description', $author->data->ID );
					$author_url = home_url( '/author/' ) . get_the_author_meta( 'nicename', $author->data->ID ); 
					?>
					<div class="contributors-box">  
						<?php echo $author_avatar; ?> 
						
						<strong class="contributor-name">  
						<?php echo $name; ?> 
						</strong>  
						<p class="contributor-bio"> 
							<?php echo $bio; ?> 							
						</p> 
						<a class="contributor-button" href="<?php echo $author_url; ?>" title="<?php echo $name; ?>"> 
							<?php echo $post_count; ?> Articles 
						</a> 
						
					</div> 
					<?php
				}
				
				?>

				<?php comments_template( '', true ); ?>

			<?php endwhile; ?>
			
		</div><!-- #content .site-content -->
	</div><!-- #primary .content-area -->

<?php //get_sidebar( 'content' ); ?>

<?php get_sidebar(); ?>

<?php get_footer(); ?>
