• Hi,
    I have the following code:

    $args=array(
    'post_type'=>'custom_event',
    'meta_query' => array('relation'=>'OR', 
    
    array('key'=>'datefrom',
    'value'=>date("Y-m-d"),
    'compare'=>'>',
    'type'=>'DATE'),
    array('key'=>'datefrom2',
    'value'=>date("Y-m-d"),
    'compare'=>'>',
    'type'=>'DATE'),
    array('key'=>'datefrom3',
    'value'=>date("Y-m-d"),
    'compare'=>'>',
    'type'=>'DATE'),
    array('key'=>'datefrom4',
    'value'=>date("Y-m-d"),
    'compare'=>'>',
    'type'=>'DATE')
    ));
    
    $loop = new WP_Query( $args );

    I have custom fields with dates of recurring event. I want to get all the upcoming events sorted by the closest date. But whenever I run this query the load on the mysql server is very big and it takes few minutes to load the website. Any ideas why it is so heavy for the server? How can I sort the result based on the closest date?

    Thanks 🙂

The topic ‘meta_query multidimensional array very slow’ is closed to new replies.