From 8a7880f1d2655d288dc3a3c65b3970a4bcfd24e7 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Fri, 25 Feb 2022 21:07:13 -0800 Subject: [PATCH] Only unauthenticate user when parse_query is for the main query --- wp-includes/general-template.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 9f5eb4a27..185deda58 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -123,9 +123,11 @@ function wp_add_error_template_no_robots() { * will persist even after they have authenticated. * * @since 0.5 + * + * @param WP_Query $query Query. */ -function wp_unauthenticate_error_template_requests() { - if ( is_offline() || is_500() ) { +function wp_unauthenticate_error_template_requests( WP_Query $query ) { + if ( $query->is_main_query() && ( is_offline() || is_500() ) ) { wp_set_current_user( 0 ); } }