如何在Wordpress中获得作为作者子项的帖子列表
如何将帖子列为作者的子项?它应该是这样的:如何在Wordpress中获得作为作者子项的帖子列表,wordpress,menu,html-lists,Wordpress,Menu,Html Lists,如何将帖子列为作者的子项?它应该是这样的: <ul> <li>Author</li> <ul> <li>Post1</li> <li>Post2</li> </ul> </li> </ul> 在哪里可以获得帖子列表?要查询每个作者的帖子,请执行以下操作: $the_qu
<ul>
<li>Author</li>
<ul>
<li>Post1</li>
<li>Post2</li>
</ul>
</li>
</ul>
在哪里可以获得帖子列表?要查询每个作者的帖子,请执行以下操作:
$the_query = new WP_Query( 'author=123' );
或
并循环浏览每个帖子,如:
// The Loop
while ( $the_query->have_posts() ) : $the_query->the_post();
echo '<li>';
the_title();
echo '</li>';
endwhile;
// Reset Post Data
wp_reset_postdata();
$the_query = new WP_Query( 'author_name=rami' );
// The Loop
while ( $the_query->have_posts() ) : $the_query->the_post();
echo '<li>';
the_title();
echo '</li>';
endwhile;
// Reset Post Data
wp_reset_postdata();