I have several writers that range from frequent to one-time writers for my blog. On my Author page, I would like to separate out writers that have not posted an article in 6 months. It would be nice then to output those writers in a different section like "Previous Writers" or something after the other list of current writers.
Right now, the code just loops through all authors and displays them all together so I would like to add in this exclusion based on the last time they posted an article.
Specific code help is welcomed as I don't know PHP or Wordpress extremely well.
Example of code:
$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 ) { ?>
<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
// 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);
// Now that we have the posts, simulate a Loop here
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 ?>
Output something about each writer here.
<?php endwhile; ?>
</ul><!-- #author-post-list -->
<?php else: ?>
<p style="font-style:italic;">This author has not yet published any posts</p>
<?php endif; ?>
In case you want to see the full code, the Author page was built using this code.