2012-02-21 8 views
1

投稿を作成している各作者のために、私はwordpressでプロフィールページを作成しています。各ページのタイトルは、著者名と同じになります。Wordpress:著者名=現在のページタイトルの返信

このページでは、「the_content」を表示できるようにしたいと思っています。これには、著者からの6つの最新の投稿が続きます。

私がしたいのは、author_name = the_titleの投稿を表示するクエリを作成することです。

私は指定した著者(例:John Smith)のみを表示しています。

$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

完璧... –

+0

@ LiamO'Toole Plzは答えを受け取り、あなたのために働いていると+1します。 –

+0

@jogesh_p新人に通知してくれてありがとう:) –

関連する問題