First, do not query_posts
; use WP Query instead. That being said, I assume that pce_monday_open
is lower than pce_monday_close
and that you want posts between pce_monday_open
and pce_monday_close
, so I think your comparison logic is wrong. Also, you may need to set the relationship between the two meta query arrays:
$pce_arg = array(
'cat' => 6,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'pce_monday_open',
'value' => $pce_time,
'compare' => '<=' ),
array('
key' => 'pce_monday_close',
'value' => $pce_time,
'compare' => '>='
)
)
);
$query = new WP_Query( $pce_arg );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
//Loop on each post
}
} else {
// no posts found
}
wp_reset_postdata();