Skip to content

Instantly share code, notes, and snippets.

@Tsunamijaan
Created January 5, 2019 09:23
Show Gist options
  • Save Tsunamijaan/ad4e23cf6c6bf4bf297e3dd3451db8b6 to your computer and use it in GitHub Desktop.
Save Tsunamijaan/ad4e23cf6c6bf4bf297e3dd3451db8b6 to your computer and use it in GitHub Desktop.
Show author more post
Use in theme functions.php file================
function get_related_author_posts() {
global $authordata, $post;
$authors_posts = get_posts( array( 'author' => $authordata->ID, 'post__not_in' => array( $post->ID ), 'posts_per_page' => 5 ) );
$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;
}
To us================e in position================
< ?php echo get_related_author_posts(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment