在主题的根文件夹中创建一个文件并将其另存为,home.php
然后将以下代码粘贴到该文件中即可完成。
<?php
get_header();
$ids = get_users( array('role' => 'editor' ,'fields' => 'ID') );
$args = array(
'post_type'=>'post',
'post_status'=>'publish',
'author' => implode(',', $ids)
);
$query = new WP_Query($args);
if($query->have_posts()) :
while ($query->have_posts()) : $query->the_post();
// code goes here, for example
echo the_title() . '<br />'; // prints title of each post
endwhile;
endif;
get_sidebar();
get_footer();
?>
Run Code Online (Sandbox Code Playgroud)