Been there. Even WP5.9 is not fully compat with PHP 8+ (yet, soon, I hope).
Have you tried PHP 7.4X?
Info: https://make.wordpress.org/core/2022/01/10/wordpress-5-9-and-php-8-0-8-1/
Hi @swansonphotos, thanks for the follow-up and for the official announcement link.
And yes, it works as expected with PHP 7.4 – problem is, the client wants PHP 8.
But I’m happy to see that the fact that WP5.9 is not fully compat with PHP 8+ is an official information – this is something I can use to persuade him to stay with 7.4 for now.
Quick update – I’m resetting this to ‘not resolved’.
The reason why I think this ticket should remain open is that the information in the official announcement (and the potential temporary fixes/polyfills) doesn’t include/cover anything about the specific problem reported here.
The get_posts query I use in the AJAX callback function is totally by the book – yet it totally doesn’t work. AND it starts working as expected as soon as it’s tested anywhere else but in an AKAX callback function.
I’m attaching the query I use, maybe/hopefully someone notices something I didn’t:
$mealtype_mq_Arr = array(
'relation' => 'OR',
array(
'key' => 'kmp-cf-mealtype',
'value' => 'breakfast',
'compare' => 'LIKE',
),
array(
'key' => 'kmp-cf-mealtype',
'value' => 'lunch',
'compare' => 'LIKE',
),
array(
'key' => 'kmp-cf-mealtype',
'value' => 'dinner',
'compare' => 'LIKE',
),
);
// + similar definitions of the $diettype_mq_Arr, $sensitivity_mq_Arr,
// $complexity_mq_Arr arrays.
// (...)
$query_args_Arr = array(
'post_status' => 'publish',
'post_type' => 'kmp-meal',
'posts_per_page' => -1,
'meta_query' => array(
'relation' => 'AND',
$mealtype_mq_Arr,
$diettype_mq_Arr,
$sensitivity_mq_Arr,
$complexity_mq_Arr,
)
);
$posts_Arr = get_posts( $query_args_Arr );
foreach ( $posts_Arr as $post ) :
$pid = $post->ID;
// (...)
endforeach;
👍 Solved.
With the latest WP version, I can’t replicate the issue anymore, meaning the core WP dev team fixed the bug.