将WP_Query导入脚本?

I wrote a script for myself but I can't execute it. First lines in my code:

$products_IDs = new WP_Query( array(
    'post_type' => 'product'
));

and there he says:

PHP Fatal error: Uncaught Error: Class 'WP_Query' not found in 
/var/www/vhosts/gmks/httpdocs/cronjob/after_update.php:10
Stack trace:
#0 /var/www/vhosts/gmks/httpdocs/cronjob/after_update.php(7): delold()
#1 {main}
thrown in /var/www/vhosts/gmks/httpdocs/cronjob/after_update.php on line 10

How can I import the WP_Query Class?

Greetings and Thank You! :)

I see that you've created a cronjob and you're pointing it to a PHP file that references WP_Query outside of the context of the entire WordPress installation.

Rather point the cronjob to something like : http://yourdomain.com/?wp_custom_cron=my_custom_action

Then create a custom WP Plugin with the following code:

<?php
/**
 * Plugin name: my custom cron job
 */

add_action( "init", "my_custom_cron_job_check" );
function my_custom_cron_job_check() {
    if ( isset( $_GET['action'] ) ) {
        if ( $_GET['action']== 'my_custom_action' ) {
            $products_IDs = new WP_Query( array(
                'post_type' => 'product'
            ));
            /* do what you need to here */

            die();
        }
    }
}
?>