Wordpress本身不直接在数据库中存储此信息。。。但您有一些优雅的选择:
您可以挂接到“发布帖子”并更新“活动用户”列表。当有人发布其发布的帖子时,您可以将此信息存储在序列化数组的选项表中。在这个数组中,您可以拥有作者列表以及他们发布最后一篇文章的时间,您可以使用该列表来选择最近的活动。。。
或
您只需编辑这一个php模板,在打印输出之前,您必须遍历所有作者,并在foreach循环中相应地将他们分开。。。为了加快页面速度,您可以将过滤后的用户或页面的全部内容存储在wordpress transient中,您可以在其中轻松兑现数组或计划html输出,请参阅wordpress transient api:http://codex.wordpress.org/Transients_API
或
您可以简单地跳过最后一篇帖子超过6个月的autor,如下所示:
<?php
// Arguments to pass to get_users
// ************* $args = array( \'orderby\' => \'post_count\', \'order\' => \'DSC\', \'who\' => \'authors\' );
// Query for the users
$authors = get_users(\'orderby=post_count&order=DSC\'); //&role=contributor ?>
<h4 style="padding-top:20px;">Writers</h4>
<?php
// Loop through all the users, printing all of their posts as we go
foreach ( $authors as $author ) {
// Set up a Loop, querying for all of the current user\'s posts
$args = array( \'author\' => $author->ID, \'posts_per_page\' => 1 );
$posts = query_posts($args);
if (6 < (date(\'n\',(time() - strtotime($posts[0]->post_date)))))
continue; //skips this autor as long as his last post is older than 6 months, be aware that this check uses date function.
?>
<a name="<?php echo $author->user_nicename; ?>"></a>
<div class="author-posts-wrapper" id="author-<?php echo $author->ID; ?>-posts-wrapper">
<div class="author-avatar" id="author-<?php echo $author->ID; ?>-avatar">
<?php echo get_avatar( $author->ID, 96 ); ?>
</div>
<div class="author-posts" id="author-<?php echo $author->ID; ?>-posts">
<h2><a href="<?php echo get_author_posts_url( $author->ID ); ?>"><?php echo $author->display_name; ?></a></h2>
<?php if ( have_posts() ) : ?>
<ul class="author-post-list" id="author-<?php echo $author->ID; ?>-post-list">
<?php while ( have_posts() ) : the_post(); // Print whatever we want for each post - for now the title ?>
<div class="author-descrip" style="padding-bottom:2px;">
<?php the_author_meta("description"); ?></div>
<p style="font-size:14px; color:#555;"><strong><?php the_author_posts(); ?> articles written. Most recent: <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></strong></p>
<p style="padding-top:8px;">
<?php if(get_the_author_meta(\'user_url\')): ?>
<?= get_the_author_meta(\'user_url\') ?>
<?php endif; ?>
</p>
<?php endwhile; ?>
</ul><!-- #author-post-list -->
<?php else: ?>
<p style="font-style:italic;">This author has not yet published any posts</p>
<?php endif; ?>
</div><!-- #author-posts -->
</div><!-- #author-posts-wrapper -->
<br />
<?php } // End looping over all users ?>