Filter date range
Hi!
I have a CPT with 2 ACF fields used to setup a date range validity for each posts.
The first ACF defines the from date, the second one defines the to date.
Now I need to create a date range filter in the backand, with the aim to filter these posts to search all the posts planned in a certain period (for example “all the post that will be visible in the month of february”).
Take this example:
Post “test 1” ACF_from 01/01/2023 ACF_to 31/01/2023
Post “test 2” ACF_from 01/01/2023 ACF_to 31/03/2023
Post “test 3” ACF_from 01/02/2023 ACF_to 28/02/2023
Post “test 4” ACF_from 09/02/2023 ACF_to 30/04/2023
Now I’m going to make this kind of filter:
“Filter all the posts visible inside this range: from 01/02/2023 to 28/02/2023”
What I need as search result is:
Post “test 2” ACF_from 01/01/2023 ACF_to 31/03/2023
Post “test 3” ACF_from 01/02/2023 ACF_to 28/02/2023
Post “test 4” ACF_from 09/02/2023 ACF_to 30/04/2023
Also “test 2” and “test 4”, because has ACF_to date bigger than the to date searched, so I know that these post will be visible in the date range I search.
Thanks!
You must be logged in to reply to this topic.