twentyfourteen_list_authors

Print a list of all site contributors who published at least one post.

Description

twentyfourteen_list_authors(); 

Usage

  1. if ( !function_exists( 'twentyfourteen_list_authors' ) ) { 
  2. require_once '/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = twentyfourteen_list_authors(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/functions.php  
  1. function twentyfourteen_list_authors() { 
  2. $contributor_ids = get_users( array( 
  3. 'fields' => 'ID',  
  4. // 'orderby' => 'post_count', // WPCOM disabled, see #2023-wpcom-themes 
  5. 'order' => 'DESC',  
  6. 'who' => 'authors',  
  7. ) ); 
  8.  
  9. foreach ( $contributor_ids as $contributor_id ) : 
  10. $post_count = count_user_posts( $contributor_id ); 
  11.  
  12. // Move on if user has not published a post (yet). 
  13. if ( ! $post_count ) { 
  14. continue; 
  15. ?> 
  16.  
  17. <div class="contributor"> 
  18. <div class="contributor-info"> 
  19. <div class="contributor-avatar"><?php echo get_avatar( $contributor_id, 132 ); ?></div> 
  20. <div class="contributor-summary"> 
  21. <h2 class="contributor-name"><?php echo get_the_author_meta( 'display_name', $contributor_id ); ?></h2> 
  22. <p class="contributor-bio"> 
  23. <?php echo get_the_author_meta( 'description', $contributor_id ); ?> 
  24. </p> 
  25. <a class="button contributor-posts-link" href="<?php echo esc_url( get_author_posts_url( $contributor_id ) ); ?>"> 
  26. <?php printf( _n( '%d Article', '%d Articles', $post_count, 'twentyfourteen' ), $post_count ); ?> 
  27. </a> 
  28. </div><!-- .contributor-summary --> 
  29. </div><!-- .contributor-info --> 
  30. </div><!-- .contributor --> 
  31.  
  32. <?php 
  33. endforeach;