Home › Forums › General Issues › How can I filter based on number of days? › Reply To: How can I filter based on number of days?
I’d imagine instead of saying duration of 3 days, just take the dates and check for posts that have availability on all days in question. So check if a room is available on ALL April 1st, 2nd, and 3rd. If all dates are available then show it.
Without knowing to much about the project I’d imagine this to check a calendar and just loop through the dates between the start and end dates and check for each day is available on the calendar.
$desired_dates = array();
for ($date = $start_date; $date <= $end_date; $date->modify('+1 day')) {
$desired_dates[] = $date->format('Y-m-d');
}
Hope this helps 👍 code is untested
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.