Home › Forums › General Issues › Using WP meta query to show custom post types by a start and finish date › Reply To: Using WP meta query to show custom post types by a start and finish date
You could possible ditch the BETWEEN and instead use two meta queries, I’ve done this myself a while back. Here’s some code modified to your example
//gets all posts that has not yet ended
$args = array(
'post_type' => 'events',
'orderby' => 'date',
'posts_per_page' => 50,
'order' => 'ASC',
'orderby' => 'meta_value_num',
'meta_key' => 'start_date',
'meta_query'=> array(
array(
'key' => 'end_date',
'compare' => '>',
'value' => "$month_end_date",
)
array(
'key' => 'start_date',
'compare' => '<',
'value' => "$month_start_date",
)
)
);
$events = new WP_Query($args);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.