2012-02-21 44 views
1

我在wordpress中創建每個作者創建帖子的個人資料頁面。每個頁面標題將與作者姓名相同。WordPress的:返回的職位作者名稱=當前頁標題

在此頁面上,我希望能夠顯示'the_content',這將成爲作者的一些圖像和生物,然後是他們的6個最新帖子。

我想要做的是創建一個查詢,顯示author_name = the_title的帖子。

目前我有這個只顯示我指定的作者(如約翰史密斯)。

$author_posts = new WP_Query(); 
$author_posts->query(array('author_name' => 'John Smith', 'posts_per_page' => 6)); 


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

//DISPLAY POST CONTENT 

endwhile; 

回答

2

您可以使用get_the_title()函數。

$author_posts = new WP_Query(); 
$author_posts->query(array('author_name' => get_the_title(), 'posts_per_page' => 6)); 


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

//DISPLAY POST CONTENT 

endwhile; 

看到這個鏈接,瞭解更多關於get_the_title()函數。

http://codex.wordpress.org/Function_Reference/get_the_title

+0

完美...作品一種享受! – 2012-02-21 04:22:06

+0

@ LiamO'Toole Plz接受答案,+1如果它爲你工作.. – 2012-02-21 06:56:23

+0

@jogesh_p感謝您通知新人:) – 2012-02-21 08:48:59

相關問題