More posts from the current author

This will retrieve the posts of current author when used in the loop.

Put the following in your theme functions.php:

function my_get_display_author_posts() {
    global $authordata, $post;

    $authors_posts = get_posts( array( 'author' => $authordata->ID, 'post__not_in' => array( $post->ID ) ) );

    $output="<ul>";
    foreach ( $authors_posts as $authors_post ) {
        $output .= '<li><a href="' . get_permalink( $authors_post->ID ) . '">' . apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '</a></li>';
    }
    $output .= '</ul>';

    return $output;
}

And add echo my_get_display_author_posts(); in your template file, within the loop where you want the posts displayed.

Leave a Comment