2014-06-21 36 views

回答

0

示例代碼

<?php 

$the_query = new WP_Query(array('posts_per_page'=>20,'author'=>$put_author_id_here)); 

while ($the_query->have_posts()) : the_post(); 

/* display the post as you do in loop*/ 

endwhile; 

wp_reset_postdata(); 

?> 
+0

如果有多個作者,它將如何工作 –

+0

只有單個作者可以發帖子,所以作者ID只有一個值 – Ashish

+1

只是創建一個函數,它將作者id作爲參數來獲取該作者的帖子,並在任何只傳遞作者ID的地方使用它 – Ashish

0

使用

query_posts('posts_per_page=20&author=$ID'); 

或使用

query_posts('posts_per_page=20&author_name="admin"'); 
+0

它只顯示了最近的文章中,我想從作者:( –

+0

使用後我告訴或使用wp_query代替 – Ashish

相關問題