• I need to show, at the home page of my multi-author WP blog, one post per author only, the most recent one of each author.

    Does anyone have already a written plugin or some PHP code to do this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • <?php query_posts('author_name=admin&showposts=1'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php the_content(); ?>
    // and other output
    <?php endwhile;?>

    Repeat the above code as many as authors you have

    More info:
    http://codex.wordpress.org/The_Loop#Multiple_Loops
    http://codex.wordpress.org/Template_Tags/query_posts#Author_Parameters

    Thread Starter estupefactus

    (@estupefactus)

    Thanks.
    But I would like to do it dinamically in two senses:
    1) I would like to order the posts-per-author by date, so that the most recent post from an author stays on top.
    2) I would like to have a piece of code that would show as many posts as authors automatically.

    Thread Starter estupefactus

    (@estupefactus)

    Hi,
    Noone ever found this need?

    I am in need of that also. I’ve ugraded to WP 2.01 but haven’t found a way to get that done yet.

    Not sure how good this coding is but it seems to do the job.

    <?php $query = "SELECT ID, user_nicename from $wpdb->users ORDER BY display_name"; ?>
    <?php $authors = $wpdb->get_results($query); ?>

    <?php foreach ( $authors as $author ) {; ?>
    <?php rewind_posts(); ?>
    <?php query_posts('author=' . $author->ID . '&showposts=1'); ?>

    <?php while (have_posts()) : the_post(); ?>
    <?php the_content(); ?>
    <?php the_author(); ?>
    <?php endwhile;?>

    <?php }; ?>

    Thanks Michael, I got something very similar to what you posted working the other day. I pasted the relevant part of the function into pastebin. The function pulls 1 post per author from a particular category. I named the category “permanent”. It also displays the author’s description which I am allowing HTML inside of, thats why the html_entity_decode is in there.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘One post per author’ is closed to new replies.