if( isset($_POST['date']) && $_POST['date']) {
$args = array(
'post_status' => 'publish',
'post_type' => 'webinars',
'meta_key' => 'date',
'orderby' => 'meta_value', // we will sort posts by date
'order' => $_POST['date'] // ASC or DESC
);
} elseif ( isset($_POST['title']) && $_POST['title']){
$args = array(
'post_status' => 'publish',
'post_type' => 'webinars',
'orderby' => 'title',
'order' => $_POST['title']
);
} elseif ( isset($_POST['price']) && $_POST['price'] ){
$args = array(
'post_status' => 'publish',
'post_type' => 'webinars',
'meta_key' => 'price',
'orderby' => 'meta_value',
'order' => $_POST['price']
);
} elseif ( isset($_POST['video_type']) && $_POST['video_type'] ){
$args = array(
'post_status' => 'publish',
'post_type' => 'webinars',
'meta_key' => 'video_type',
'orderby' => 'meta_value', // we will sort posts by date
'order' => $_POST['video_type'] // ASC or DESC
);
} elseif( isset( $_POST['webinars_genre'] ) ){
$args['tax_query'] = array(
array(
'taxonomy' => 'webinars_genre',
'field' => 'id',
'terms' => $_POST['webinars_genre']
)
);
} elseif( isset( $_POST['webinars_artist'] ) ){
$args['tax_query'] = array(
array(
'taxonomy' => 'webinars_artist',
'field' => 'id',
'terms' => $_POST['webinars_artist']
)
);
} elseif ( isset($_POST['duration']) && $_POST['duration'] ){
$args = array(
'post_status' => 'publish',
'post_type' => 'webinars',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'duration',
'value' => $_POST['duration'],
'compare' => 'LIKE',
),
),
);
} elseif ( isset($_POST['month']) && $_POST['month'] ) {
// var_dump($_POST);
$args = [
'post_status' => 'publish',
'post_type' => 'webinars',
'meta_key' => 'date',
'meta_type' => 'DATETIME',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => [
'relation' => 'OR',
],
];
foreach ( $_POST['month'] as $month ) {
$args['meta_query'][] = [
'key' => 'date',
'type' => 'DATETIME',
'value' => $month,
'compare' => 'LIKE',
];
}
} elseif ( isset($_POST['day']) && $_POST['day'] ) {
// var_dump($day);
$args = [
'post_status' => 'publish',
'post_type' => 'webinars',
'meta_key' => 'day',
'meta_type' => 'DATETIME',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => [
'relation' => 'OR',
],
];
foreach ( $_POST['day'] as $day ) {
$args['meta_query'][] = [
'key' => 'day',
'type' => 'DATETIME',
'value' => $day,
'compare' => 'LIKE',
];
}
} else {
$args = array(
'post_status' => 'publish',
'post_type' => 'webinars',
'orderby' => 'title',
'order' => 'ASC',
);
}