Advertisement
danfolt

WP author posts

Nov 23rd, 2011
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.50 KB | None | 0 0
  1. function get_related_author_posts() {
  2.     global $authordata, $post;
  3.  
  4.     $authors_posts = get_posts( array( 'author' => $authordata->ID, 'post__not_in' => array( $post->ID ), 'posts_per_page' => 5 ) );
  5.  
  6.     $output = '<ul>';
  7.     foreach ( $authors_posts as $authors_post ) {
  8.         $output .= '<li><a href="' . get_permalink( $authors_post->ID ) . '">' . apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '</a></li>';
  9.     }
  10.     $output .= '</ul>';
  11.  
  12.     return $output;
  13. }
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement