date_query in pre_get_posts out of memory
I'm trying to apply a Datefilter for specific categories.
Wordpress crashs with a out of memory error. Is this a server problem or is my query wrong? At first I tried query - (...) but with approach I get an error, cause of too few arguments. While using query = new WP_Query... I get the out of memory error.
Thank you for your help.
My code:
function test_filter( $query ) {
$options = get_option('dh_options');
$cats = 54,55,56;
if ($options['checkbox_usr_q'] == true) {
if ( !is_admin() $query-is_main_query() $query-in_category($cats)) {
$args = array(
'date_query' = array(
array(
'column' = 'post_date_gmt',
'after' = 'May 1st, 2021',
'inclusive' = true
),
),
'posts_per_page' = -1
);
$query = new WP_Query( $args );
}
}
}
add_action( 'pre_get_posts', 'test_filter' , 100, 3);
Error Message:
Fatal error: Out of memory (allocated 699400192) (tried to allocate 262144 bytes) in /homepages/1/d861373325/htdocs/wp/wp-includes/class-wp-query.php on line 892
Fatal error: Out of memory (allocated 699400192) (tried to allocate 262144 bytes) in /homepages/1/d861373325/htdocs/wp/wp-includes/class-wp-recovery-mode.php on line 361
Topic date-query pre-get-posts fatal-error wp-query Wordpress
Category Web