Skip to content

Instantly share code, notes, and snippets.

@Faisalawanisee
Last active February 10, 2019 20:26
Show Gist options
  • Save Faisalawanisee/26e4038953939f8ba2b6f9628c71a889 to your computer and use it in GitHub Desktop.
Save Faisalawanisee/26e4038953939f8ba2b6f9628c71a889 to your computer and use it in GitHub Desktop.
<?php
$min_meta = $max_meta = [];
if(isset($_GET['min_date']) || $_GET['max_date']) {
if(isset($_GET['min_date'])) {
$min_meta = array(
'key' => 'min_date',
'value' => $_GET['min_date'],
'compare' => '='
);
}
if(isset($_GET['max_date'])) {
$max_meta = array(
'key' => 'max_date',
'value' => $_GET['max_date'],
'compare' => '='
);
}
}
$args = array(
'post_type' => 'event',
'meta_query' => array($min_meta, $max_meta),
);
$query = new WP_Query( $args );
if($query->have_posts()){
while($query->have_posts()){ $query->the_post();
}
}
wp_reset_postdata();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment