我的博客上有一个贡献者页面,我最近开始使用一些在线代码,这很好。
然而
我希望它能做两件额外的事情:
1) 仅列出在网站上至少有一篇批准帖子的成员2)列出之前5篇帖子的成员
这是我目前使用的代码,
<?php /*
Template Name: Authors
*/ ?>
<?php get_header(); ?>
<div id="content" class="clearfix">
<div id="main" class="col620 clearfix" role="main">
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<h1 class="entry-title"><?php the_title(); ?></h1>
</header><!-- .entry-header -->
<div class="entry-content post_content">
<?php the_content(); ?>
</div>
<?php endwhile; endif; ?>
<?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 = \'wavatar\';
?>
<div id="container" style="padding:10px 10px;">
<div class="author single_postmeta">
<a href="<?php echo $user_link; ?>" title="<?php echo $curauth->display_name; ?>">
<?php echo get_avatar($curauth->user_email, \'96\', $avatar); ?>
</a>
<h3 class="post-title">
<a href="<?php echo $user_link; ?>" title="<?php echo $curauth->display_name; ?>"><?php echo $curauth->display_name; ?></a><br>
<?php if(get_the_author_meta(\'jobtitle\', $curauth->ID)): ?>
<?php the_author_meta(\'jobtitle\', $curauth->ID); ?> at <?php the_author_meta(\'company\', $curauth->ID); ?>
<?php endif; ?>
</h3>
<br>
<p><?php echo $curauth->description; ?> </p>
<br>
<ul>
<?php if(get_the_author_meta(\'twitter\', $curauth->ID)): ?>
<li><a href=\'http://twitter.com/<?php the_author_meta(\'twitter\', $curauth->ID); ?>\'>Follow <?php the_author_meta(\'first_name\', $curauth->ID); ?> on twitter →</a></li>
<?php endif; ?>
<?php if(get_the_author_meta(\'facebook\', $curauth->ID)): ?>
<li><a href=\'<?php the_author_meta(\'facebook\', $curauth->ID); ?>\'>Find <?php the_author_meta(\'first_name\', $curauth->ID); ?> on Facebook →</a></li>
<?php endif; ?>
<?php if(get_the_author_meta(\'linkedin\', $curauth->ID)): ?>
<li><a href=\'<?php the_author_meta(\'linkedin\', $curauth->ID); ?>\'>Connect with <?php the_author_meta(\'first_name\', $curauth->ID); ?> on Linkedin →</a></li>
<?php endif; ?>
<?php if(get_the_author_meta(\'googleplus\', $curauth->ID)): ?>
<li><a href=\'<?php the_author_meta(\'googleplus\', $curauth->ID); ?>\'>Add <?php the_author_meta(\'first_name\', $curauth->ID); ?> to your circle on Google+ →</a></li>
<?php endif; ?>
</ul>
</div>
</div>
<?php endif; ?>
<?php endforeach; ?>
</article>
<?php get_footer(); ?>
非常感谢您的帮助,
谢谢詹姆斯