Skip Navigation

[Resolved] Display posts with certain repeatable field

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 2 months, 3 weeks ago.

Author
Posts
#2737167

Hello,
I have CPT "Tours" which has amongst other fields a Repeatable Group with Tour Start and Tour End dates - as dates fields.

Now, I would like to end up with a view that would separate search form and results form to different pages (no problem, I know how to do that). But - in the search form I would like to have e.g. select dropdown (or anything else) that would consist of Start date field values of the Tours posts, grouped by same values. And after selection of a date (e.g. August 2024), all Tours with Start date in August 2024 would show up.
After hours of failing I think this approach is not solvable, but since each Tour (e.g. Trip to Madeira) has several terms, each term with different prices, guides, tracks, etc., I see no other option than to use the Repeatable Group. But Repeatable Group fields require a separate View to display, I am afraid I will not be possible to create a View as desired. I think it would be possible to create a hierarchical taxonomy with years and months, but I would love to keep the administration as simple as possible, so that the client doesn't have to set dates twice (once in the RG exact dates, and in the taxonomy general dates)

Any ideas on this, please?
Thanks very much in advance,
Tom

#2737674

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Tom

You are correct to identify the problem as relating to how repeatable field groups are stored.

They are implemented via child posts and each field belongs to the child post rather than the parent directly.

To illustrate, let's use an example with an Offices repeatable group of fields, that has individual fields for Phone, Email, Manager, and City.

Custom fields are stored in wp_postmeta and always belong to a specific post.

We add several Offices groups to our Acme, Inc post, filling in details for each of the fields.

So, in wp_postmeta, attached to the Acme, Inc post we have several phone numbers, several email addresses, managers, and cities. But nothing to connect a particular phone number to the associated email address, manager, and city, they are mixed up. (We'd essentially need an extra column in the table to group the field entries.)

The Toolset solution is to store each group of fields against a child post of the Acme, Inc post. As many child posts are added as groups of fields are added, one for each Office in our example. That means the fields like phone and email address belong to the child office post, not to the original Acme, Inc post.

That's why you would use a View to output the repeatable groups of fields belonging to the Acme, Inc post, for example, where the View actually queries the child post type.

And so the problem in your case is that you cannot filter one post type by the properties of another.

If you are only filtering by date then you could use a View which queries the child RFG posts, because in the output of the View you can output fields of the parent Tour posts (so a Tour title linking to the Tour post, for example).

But if you were also filtering by other fields or taxonomies of Tours then you would need the View to be querying the Tour post type, in which case you would need date fields (or terms) that belonged directly to the Tour posts to be able to filter by them. To improve the experience for your users you would likely want to use some code to automate that, so that when a post with date RFG fields was saved, they were duplicated in some way on the Tour post itself.

#2737677

Hello, Nigel,
ok, I get it now, thanks very much for your explanation.
So in this case, I will create some hierarchical taxonomy and make the filter out it
eg.
2024
- 09
- 10
- 11

2025
- 01
- 02
- 03
etc.

The administration of each Tour will become slightly more complicated but I don't see any other way.
Thanks very much!