0
我已經改變了我的方法,並編輯了get_related_author作用,但它只能引入1篇文章,可以有人看到我要去哪裏錯了?WordPress的作者查詢
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));
foreach ($authors_posts as $authors_post) {
$output = '<div class="listio"><ul><li> <div class="author-post">';
$output .= '<div style="background: url(<?php echo $src[0]; ?>) !important;
width: 80px; height: 50px; float: left; margin-right: 13px;
background-size: 80px 50px!important; background-color: pink;"></div>';
$output .= '<a href="' . get_permalink($authors_post->ID) . '">' .
apply_filters('the_title', $authors_post->post_title, $authors_post->ID) .
'</a>';
$output .= '</div></li></ul></div>';
}
return $output;
}
你需要從外循環得到作者的ID。然後創建$ wpdb查詢來獲取作者的所有帖子。 –
有什麼想法?任何人在這? –