How to list the 4 latest posts with only one post per author in WordPress

wpgblogs

Recently, one site we were working on needed a sidebar that would show the 4 most recent posts on the site. But here’s the catch: they wanted only one post per author. And, each author had to have the role of “author” as opposed to contributor or admin.
The site in question is still in Beta, so I can’t give out the link yet. But here’s a snapshot to give you a better idea of what we were going for.

We also used the plugin User Photo to show each author’s thumbnail, which I have come to love and recommend.
Thanks to Mark Kaplun for this great solution:
Open your Sidebar.php file and add the following:
Please note: this code uses the plugin Limit Posts to create excerpts. But you can substitute that snippet with any type of excerpt code.
<?php $authors = get_users_of_blog(); ?>
<?php
$latest_posts = array();
foreach…

You Might Also Like...

  • Optimise Your WordPress Themes With Better Author Pages

    1885 readersRecently Ajay D’Souza asked how we made our author archive pages here on BloggingPro. I personally am a big fan of displaying content differently on different sections of blogs and also think that archives should be more informative than be just a collection of excerpts. Because I personally believe that an ‘Author Information’ block below every

  • Display most recent comments with Gravatar

    1523 readersIs your blog popular? Do you got receive lots of comments from your readers? If yes, what about displaying the most recent comments in your blog sidebar (or elsewhere) to let your visitors knowing about the discussion?Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!Display

  • Display posts from specific categories on a Page

    379 readersYou may want to display posts from a specific category on the homepage or other pages of your site. For example, you might want to have a box that displays the latest three posts from your News category, or have links to your latest podcasts. In a previous post, I gave the code that would display

  • How to create a Simple Directory in Wordpress using Grandparent, Parent, and Child Pages

    317 readersI wanted to create a simple directory of non-profit organizations. To do so,  I wanted to use pages for the directory, rather than posts so that I could separate the static directory listings from the dynamic blog posts. I didn’t want to have to exclude tons of categories from feedburner and the main loop. So,

  • How to Create a Comments Central Page Template in WordPress

    295 readersOne way to increase visitor engagements is to reward their comments by showcasing them on your website. Additionally, you can also feature the top commenters as well, linking back to their website in the process. Here we’ll create a dedicated Page Template to display those comments and commenters in one place. In short, this tutorial

  • My profile and Twitter link

    Adding and using custom user profile fields

    707 readersHow to create and display custom user profile fields in WordPress that allow users to input additional information about themselves.

  • How to list Pages with custom fields in 2 columns in WordPress

    1837 readersRecently, I needed to list all subpages of a parent page.  I also needed to display custom fields below each subpage. And, on top of that, the list needed to be 2 columns. I found a solution for simply listing the pages in 2 columns, but it did not suggest how to modify the code to

  • Display Gravatar & Autofill Fields for Previous Commenter

    772 readersWhen someone comments on your site, cookies with the information the entered are saved to their computers. WordPress makes it easy to access that information. In fact, in your comments.php template they are ready-to-go PHP variables you can spit out anywhere you’d like. Let’s take a look. Here are the most important ones, when it comes

  • Display sticky post and exclude it from recent posts list in WordPress

    1486 readersWe were working on a WordPress site that needed to display a sticky post at the top of the blog page with one style, and then below it a list of the most recent posts with a completely different style. I realize that you can just style the sticky post using the sticky-related classes provided by

  • WordPress hack: Get popular posts by comments count

    2642 readersIn blogging, it is useful to be able to display your most popular posts. There's WordPress plugins to do that, but you don't need it: This code will display your most popular posts, accordoing to the comments count, without requiring you to use a plugin.Looking for WordPress hosting? Try WP Web Host. Prices starts at