KoderyBeta

Newest post from each author

Category: WordPress - Owner: PaulDavis - Owner ID: 1

Gets the newest post from each author, if they have actually posted.

<ul>
	<?php
		$authors = get_users_of_blog();
		$latest_posts = array();
		foreach ($authors as $author) {
			$user = new WP_User( $author->ID );
			if ($user->has_cap('level_7')) continue;
			$ps = get_posts('numberposts=1&post_type=post&author='.$author->ID);
			foreach ($ps as $p) {
				$latest_posts[$p->post_date] = $p;
			}
		}
		krsort($latest_posts);
	
		foreach ($latest_posts as $post) {
			setup_postdata($post);
		?>
		<li>
			<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
		</li>
	<?php } ?>
</ul>