According to the WP_Query::parse_args
docs (which is what parses the $args
you’re passing to get_posts()
), the $author
parameter needs to be an int
or a string
(a comma-separated list of IDs).
But you’re also going to need this set up in groups, per student, so here’s what I’d recommend: use an array to store each student’s posts, then print them out once you’ve got them all.
$students = get_users( array(
'role' => 'student',
'orderby' => 'user_nicename',
'order' => 'ASC'
'has_published_posts' => true
));
$students_posts = array();
foreach ($students as $student) {
$get_posts_student = get_posts( array(
'author' => $student->ID,
'post_type' => array('dissertation', 'subject-imposed', 'subject-free')
));
$students_posts[ $student->ID ] = array(
'name' => $student->user_nicename,
'posts' => $get_posts_student,
);
}
This should give you an array of students and their posts that you can then loop through and display.