From 79339c4a7d91101a531264811d31fe5a8a2c1386 Mon Sep 17 00:00:00 2001 From: Matt Pramschufer Date: Tue, 7 Feb 2023 13:39:37 -0500 Subject: [PATCH] Try to get author first by author_id then if not set default to finding author by user_nicename. This fixes issue with all posts on author archive page being the same author even if there is other post loops on page that do not belong to author. --- co-authors-plus.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/co-authors-plus.php b/co-authors-plus.php index 951d652a..f3d6f0d0 100755 --- a/co-authors-plus.php +++ b/co-authors-plus.php @@ -1179,7 +1179,7 @@ function current_user_can_set_authors() { */ public function fix_author_page( $selection ) { - global $wp_query, $authordata; + global $wp_query, $authordata, $post; if ( ! isset( $wp_query ) ) { return; @@ -1194,7 +1194,12 @@ public function fix_author_page( $selection ) { return; } - $author = $this->get_coauthor_by( 'user_nicename', $author_name ); + if ( ! isset( $post->post_author ) ) { + $author = $this->get_coauthor_by( 'user_nicename', $author_name ); + } else { + $author = $this->get_coauthor_by( 'id', $post->post_author ); + } + if ( is_object( $author ) ) { $authordata = $author; //phpcs:ignore $term = $this->get_author_term( $authordata );