WordPress.org

Ready to get started?Download WordPress

Forums

One post per author (7 posts)

  1. estupefactus
    Member
    Posted 8 years ago #

    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?

  2. Joshua Sigar
    Member
    Posted 8 years ago #

    <?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

  3. estupefactus
    Member
    Posted 8 years ago #

    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.

  4. estupefactus
    Member
    Posted 8 years ago #

    Hi,
    Noone ever found this need?

  5. eric_ie
    Member
    Posted 8 years ago #

    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.

  6. MichaelH
    Member
    Posted 8 years ago #

    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 }; ?>

  7. eric_ie
    Member
    Posted 8 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic