Zuerst bekomme ich einen Benutzer mit der Rolle “Autor”.
$author_args = array( 'role' => 'author' ); $authors_list = get_users($author_args);
Als nächstes reformiere ich das Array
$author_list = array(); foreach((array)$authors_list as $author) $author_list[] = $author->user_nicename;
Und dann Fragen abfragen
$author_posts_args = array( 'author_name' => $author_list, 'post_type' => 'post', 'cat' => $colecti_id, 'posts_per_page' => '4', ); $author_posts_query = new WP_Query($author_posts_args);
Warum funktioniert es nicht?
Erhalte Autoren-IDs anstelle von Autorenname, um Beiträge für mehrere Autoren mit WP_Query () zu erhalten;
$author_list = array(); foreach((array)$authors_list as $author) $author_list[] = $author->ID; // make comma separated string from author ids array $author_list = implode(',', $author_list)
und ändern wp Abfrageargumente
$author_posts_args = array( 'author' => $author_list, 'post_type' => 'post', 'cat' => $colecti_id, 'posts_per_page' => '4', ); $author_posts_query = new WP_Query($author_posts_args);