首页 文章

Wordpress:返回作者姓名=当前页面 Headers 的帖子

提问于
浏览
1

我正在wordpress中为每个创建帖子的作者创建一个 Profiles 页面 . 每个页面 Headers 将等于作者姓名 .

在这个页面上,我希望能够显示'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;

1 回答

  • 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

相关问题