我正在尝试使用Meta_Query创建一个带有打开复选框的过滤器。 $ opening_time和$ closing_time的值是UNIX时间。它只能与$ status_2,$ opening_time_2,$ closing_time_2一起使用,也可以不与之一起使用。 我该如何运作?
$status = 'opening_hours_monday_day_status';
$opening_time = 'opening_hours_monday_opening_time';
$closing_time = 'opening_hours_monday_closing_time';
$status_2 = 'opening_hours_monday2_day_status';
$opening_time_2 = 'opening_hours_monday2_opening_time';
$closing_time_2 = 'opening_hours_monday2_closing_time';
$current_time = strtotime('2016-01-01 ' . current_time('h:i a'));
$element_filter_arr = array();
if ($timings == 'open') {
$element_filter_arr[] = array(
'key' => $status,
'value' => 'on',
'compare' => '=',
);
$element_filter_arr[] = array(
'key' => $opening_time,
'value' => $current_time,
'compare' => '<=',
);
$element_filter_arr[] = array(
'key' => $closing_time,
'value' => $current_time,
'compare' => '>=',
);
$element_filter_arr[] = array(
'key' => $status_2,
'value' => 'on',
'compare' => '=',
);
$element_filter_arr[] = array(
'key' => $opening_time_2,
'value' => $current_time,
'compare' => '<=',
);
$element_filter_arr[] = array(
'key' => $closing_time_2,
'value' => $current_time,
'compare' => '>=',
);
}
$args = array(
'posts_per_page' => "-1",
'post_type' => 'shop',
'post_status' => 'publish',
'fields' => 'ids',
'meta_query' => array(
$element_filter_arr,
),