Hi again! Keep on working in my travel agency site and having issues with repeatable field groups. I have a custom post type for Tours and I've created a repeatable field group for this type with several departure dates and, in each of them, a checkbox to mark if that departure date is confirmed or not. This time the issue is using this info to filter the tours in a view.
In my front page I have a view showing all the tours. I added to this view a custom search filter based on different taxonomies and custom post fields, like where do you want to travel, price, duration, type of experience. I have no problem configuring all of these filters, but I have also a departure date filter. The departure date of each tour is set, as I mentioned before, with a repeatable field group. What I'm trying to do is create a departure date filter by month, so if the user selects "January" the view shows all of the tours that have set any departure date between 01/01/2023 and 10/31/2023. When I try to select de repeatable field "fecha de salida" to set the filter, it doesn't show up.
I've read several topics related filtering with repeatable field group but I couldn't find a solution. Is possible to do this?
I'm sorry to say there isn't a good solution for what you want to do.
Repeatable Field Groups are implemented via hidden post relationships.
If you have a Tour post type and add a repeatable field group to it, the field values are not stored against the tour posts, but rather against a hidden custom post type that is a child of Tours.
When filtering Tours you can only filter by properties of Tours themselves (standard fields, custom fields, or taxonomies assigned to Tours), not by properties of another post type related to Tours.
It is an unfortunate omission, but it is a feature that has not been implemented.
It would require a custom solution to implement something like this. The first challenge is to include a filter control in the UI where users can select dates and then these chosen dates be passed along with the rest of the search submission.
You could then use the API to find the RFG posts that met the date conditions, find the Tour posts which they belong to, and then use the post__in WP_Query argument to limit the set of Tour posts that can be returned by the query.
Oh, it's sad to read that! I'll talk to my team to decide if we ask a contractor for assistance or if we try to change the tour data structuture to make possible to use the filter. Thank you for your time.