Why is wp_query causing an uncaught error to is_user_logged_in() not defined?

One of the function call was written in the global scope, and firing before all the scripts could be properly loaded. Moving the function call out of the global space, the error went away. Functions that require or use WordPress functions should not be called before WordPress has successfully loaded it’s scripts.

tech