Fatalerror: Calltoamemberfunctionget () onanon-object. Use require (BASE_PATH.wp-load.php) in your own code's function; introduce the WordPress core code, execute WP_Query to get specific logs, and then the following error occurs: use require (BASE_PATH. 'WP-load. php '); introduce the WordPress core code, execute WP_Query to obtain specific logs, and then the following error occurs:
Fatal error: Call to a member function get() on a non-object in [path to site]\site\wp-includes\query.php on line 27
This is caused by incorrect use of global variables. the default $ wp_query is defined in the wp-setting.php, because it is defined in the outermost layer, so $ wp_query is naturally a global variable. However, in your function, use require (BASE_PATH. 'WP-load. php '); introduces the WordPress core code. $ wp_query becomes the local variable in this function, so an error occurs when other code calls $ wp_query.
Solution: add the following code to the require (BASE_PATH. 'WP-load. php') code to define $ wp_query as a global variable in advance:
define('WP_USE_THEMES', false);global $wp, $wp_query, $wp_the_query, $wp_rewrite, $wp_did_header;
Revoke require (BASE_PATH. wp-load.php); introduce the WordPress core code, then execute WP_Query to get the specific log, then the following error occurs :...