Hi!
I am having a small issue building an authors list page, thanks to a page template. I can display all users, but I don't know how to limit that list to users who posted already.
Here is my code so far:
<?php /*
Template Name: Authors
*/ ?>
<?php get_header(); ?>
<div id="content">
<div class="breadcrumbs">
<?php the_breadcrumb(); ?>
</div>
<?php the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class('post'); ?>>
<h1 class="entry-title"><?php the_title(); ?></h1>
<div class="entry-content">
<?php the_content(); ?>
</div><!-- .entry-content -->
</div><!-- #post-<?php the_ID(); ?> -->
<?php
// Get the authors from the database ordered by user nicename
global $wpdb;
$query = "SELECT ID, user_nicename from $wpdb->users ORDER BY user_nicename";
$author_ids = $wpdb->get_results($query);
// Loop through each author
foreach($author_ids as $author) :
// Get user data
$curauth = get_userdata($author->ID);
// If user level is above 0 or login name is "admin", display profile
if($curauth->user_level > 0 || $curauth->user_login == 'admin') :
// Get link to author page
$user_link = get_author_posts_url($curauth->ID);
// Set default avatar (values = default, wavatar, identicon, monsterid)
$avatar = 'default';
?>
<div class="authors-desc">
<a href="<?php echo $user_link; ?>" title="<?php echo $curauth->display_name; ?>">
<?php echo get_avatar($curauth->user_email, '96', $avatar); ?>
</a>
<h2 class="post-title">
<a href="<?php echo $user_link; ?>" title="<?php echo $curauth->display_name; ?>"><?php echo $curauth->display_name; ?></a>
</h2>
<p>
<?php echo $curauth->description; ?>
</p>
<p>
<a href="<?php echo $user_link; ?>" title="<?php echo $curauth->display_name; ?>">View all his posts</a>
</p>
<div class="clear"></div>
</div>
<?php endif; ?>
<?php endforeach; ?>
</div><!-- end content -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Any idea?
Thanks!