diff --git a/includes/wc-template-functions.php b/includes/wc-template-functions.php index 1e1afc29761..9528502061e 100644 --- a/includes/wc-template-functions.php +++ b/includes/wc-template-functions.php @@ -2294,15 +2294,17 @@ if ( ! function_exists( 'woocommerce_account_content' ) ) { function woocommerce_account_content() { global $wp; - foreach ( $wp->query_vars as $key => $value ) { - // Ignore pagename param. - if ( 'pagename' === $key ) { - continue; - } + if ( ! empty( $wp->query_vars ) ) { + foreach ( $wp->query_vars as $key => $value ) { + // Ignore pagename param. + if ( 'pagename' === $key ) { + continue; + } - if ( has_action( 'woocommerce_account_' . $key . '_endpoint' ) ) { - do_action( 'woocommerce_account_' . $key . '_endpoint', $value ); - return; + if ( has_action( 'woocommerce_account_' . $key . '_endpoint' ) ) { + do_action( 'woocommerce_account_' . $key . '_endpoint', $value ); + return; + } } }