Last active
February 10, 2019 20:26
-
-
Save Faisalawanisee/26e4038953939f8ba2b6f9628c71a889 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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