Display Related Posts by “Category” “by Author”
Question
How can I display related post “by category” “by author”? I use this code but it just displays related posts by newest posts of author, not related posts by category of author. I’ve done some research on the internet but cannot find an answer.
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' => 3 ) );
$output = '<div class="rp-users">';
foreach ( $authors_posts as $authors_post ) {
$output .= '<div class="rp-user-entry">';
$output .= get_the_post_thumbnail($authors_post->ID, 'related-post-size');
$output .= '<a href="' . get_permalink( $authors_post->ID ) . '"class="rp-title">' . apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '</a>';
$output .= '</div>';
}
$output .= '</div>';
return $output;
0
author, categories
6 years
2017-08-07T10:33:48-05:00
2017-08-07T10:33:48-05:00 0 Answers
133 views
0
Leave an answer