I have a strange problem. In PHP 7.4 my script for generating XML for other comparison site worked well, but after upgrading PHP to 8.0 it doesn't work anymore.
In sandbox I got these errors:
Fatal error: Uncaught Error: Class "WP_Query" not found in /home/user/scripts/code.php:78
Stack trace:
#0 {main}
thrown in /home/user/scripts/code.php on line 78
and the code in line 78 looks like this (last line with WP_query):
// FETCH ALL PRODUCTS
$args = array(
'posts_per_page' => -1,
'post_type' => 'product'
);
if( count( $config['exclude-products'] ) ) {
$args['post__not_in'] = $config['exclude-products'];
}
// PRODUCT LIMIT (1 product can have multiple variations)
if( isset( $_GET['limit'] ) && $_GET['limit'] ) {
$args['posts_per_page'] = $_GET['limit'];
}
if( isset( $_GET['offset'] ) && $_GET['offset'] ) {
$args['offset'] = $_GET['offset'];
}
$products = new WP_Query( $args );
Can somebody help me what to do as I am not a programmer.