IngmarBoddington
8/2/2012 - 2:50 PM

Example authors page template for multi-author WordPress blogs

Example authors page template for multi-author WordPress blogs

<?php
/*
Template Name: Authors
*/
?>

<?php get_header(); ?>

			<!-- BEGIN #content-wrap -->
			<div id="content-wrap" class="clearfix">
			
				<div id="content-top">&nbsp;</div>
			
				<!--BEGIN #primary .hfeed-->
				<div id="primary" class="hfeed">
                
				<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
					
					<!--BEGIN .hentry -->
					<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
                    
						<h1 class="entry-title"><?php the_title(); ?></h1>
						
						<!--BEGIN .entry-content -->
						<div class="entry-content">
						
						 <?php the_content(); ?>
                        
							<!--BEGIN .archive-lists -->
                            <div class="archive-lists">

						<?php 
						
							//Ing - Code for displaying all authors info
							global $wpdb;
							$user_ids = $wpdb->get_col("SELECT ID FROM $wpdb->users ORDER BY user_nicename");
							$blog_name = 'The Online Retailing Blog';
							foreach ($user_ids as $user_id) {
								
								//Get all the info
								$user = get_userdata($user_id);
								list($user_description) = $wpdb->get_col("SELECT meta_value FROM $wpdb->usermeta WHERE meta_key = 'description' AND user_id = $user_id");
								list($user_first_name) = $wpdb->get_col("SELECT meta_value FROM $wpdb->usermeta WHERE meta_key = 'first_name' AND user_id = $user_id");
								$user_link = get_author_posts_url($user_id);
								$user_name = $user->data->display_name;
								$user_avatar = get_avatar($user->data->user_email, 70);
								$user_url = $user->data->user_url;
								$user_url_link = ($user_url != '' ? '<a href="' . $user_url . '">' . $user_name . '</a>' : $user_name);
								$user_post_count = count_user_posts($user_id);
								$user_post_cost_suffix = ($user_post_count == 1 ? 'post' : 'posts');								
								
								//Ensure only Authors (with more than one post) get outputted
								if (($user->caps['author'] == 1) && ($user_post_count > 0)) {
						
									//Output author block
									echo '
									<!--BEGIN .author-bio-->
									<div class="author-bio">
								
										<!-- BEGIN .author-inner -->
										<div class="author-inner clearfix">
						
											<!-- BEGIN .author-wrap -->
											<div class="author-wrap clearfix">
												' . $user_avatar . '		
												<div class="author-info">
													<div class="author-title">' . $user_url_link . '</div>
													<div class="author-description">' . $user_description . '<br />' . $user_first_name . ' has made <a href="' . $user_link . '">' . $user_post_count . ' ' . $user_post_cost_suffix . '</a> on ' . $blog_name . '</div>
												</div>
														
											<!-- END .author-wrap -->
											</div>
													
										<!-- END .author-inner -->
										</div>
													
									<!--END .author-bio-->
									</div>';
									
								}		
							}    
						?>                      
                                

                            
                            <!--END .archive-lists -->
                            </div>
                            
						<!--END .entry-content -->
						</div>

	                <!--END .hentry-->  
					</div>
	
					<?php endwhile; else: ?>
	
					<!--BEGIN #post-0-->
					<div id="post-0" <?php post_class() ?>>
					
						<h1 class="entry-title"><?php _e('Error 404 - Not Found', 'framework') ?></h1>
					
						<!--BEGIN .entry-content-->
						<div class="entry-content">
							<p><?php _e("Sorry, but you are looking for something that isn't here.", "framework") ?></p>
							<?php get_search_form(); ?>
						<!--END .entry-content-->
						</div>
					
					<!--END #post-0-->
					</div>
	
				<?php endif; ?>
				<!--END #primary .hfeed-->
				</div>
			
			<div id="content-btm">&nbsp;</div>
			
			<!-- END #content-wrap -->
			</div>

<?php get_sidebar(); ?>

<?php get_footer(); ?>