我正在一個網站上有自定義作者頁,並在作者頁上有一個最近的作者帖子小部件,顯示該作者的其他職位。這個網站有多個作者,所以每篇文章都有所不同,我還沒有找到這樣的插件。我試圖顯示帖子縮略圖,標題和類別名稱。獲取環境外的the_category
我正在使用顯示標題和縮略圖的函數,但它沒有該類別。我嘗試添加類別:the_category('','multiple',$ authors_post-> ID),不幸的是它顯示了第一個li中的所有類別。而不是每個帖子。
這裏是我的工作:
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 = '<ul>';
foreach ($authors_posts as $authors_post) {
$output .= '<li>' . get_the_post_thumbnail($authors_post->ID, 'xsmall-thumb')
. '<p>' . the_category(' ','multiple',$authors_post->ID)
. '</p> <a href="' . get_permalink($authors_post->ID)
. '">' . apply_filters('the_title', $authors_post->post_title,
$authors_post->ID) . '</a></li>';
}
$output .= '</ul>';
return $output;
}
任何幫助將不勝感激, 謝謝!
謝謝,但這似乎並沒有工作:( – user1272433 2013-04-08 05:42:42
它應該與'get_the_category($ cat_id)'... – 2016-05-02 09:58:50