Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Wordpress中获得作为作者子项的帖子列表_Wordpress_Menu_Html Lists - Fatal编程技术网

如何在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();