Skip to content

Instantly share code, notes, and snippets.

/search.php Secret

Created October 10, 2016 12:17
Show Gist options
  • Save anonymous/96b776af76620ef7e7d3edc0f0315349 to your computer and use it in GitHub Desktop.
Save anonymous/96b776af76620ef7e7d3edc0f0315349 to your computer and use it in GitHub Desktop.
<?php
$args = array('posts_per_page' => 5,
'orderby' => 'post_title',
'order' => 'ASC',
'post_type' => 'tour',
'post_status' => 'publish',
'paged' => $paged);
$sdate = !empty($_GET['sdate']) ? sanitize_text_field($_GET['sdate']) : 0;
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$meta_q = array('relation' => 'AND');
if($sdate){
$start_date = date('Ymd', strtotime($sdate));
$meta_q[] = array('key' => 'date_and_price_%_date', 'value' => '"' .$start_date. '"', 'compare' => '<=');
}
if(count($meta_q) > 1)
$args['meta_query'] = $meta_q;
$wp_query = new WP_Query($args);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment