Skip Navigation

[Resolved] Custom search doesn't work with repeteable field of repeteable group

This support ticket is created 4 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 12 replies, has 2 voices.

Last updated by David Gimenez 4 years, 8 months ago.

Assisted by: Nigel.

Author
Posts
#1565315

Hi there. First of all I explain the estructure and after the problem

I have a custom post type called menu (restaurant menu). That custom post type has got several custom fields and a repeteable group called / named preus (prices). One menu can have different prices (half menu, full menu...). I can add a price clicking in add price (repeteale field)

Example

Shane menu
12€ full menu
8€ half menu

David Menu
16€ full menu
9€ half menu
6€ half menu of cold starters

If I do a custom search of menu that have a price equal or lower than 20, the custom search has no results. To try to find what is happening... I added a new single custom field to menu called preu fantasma (ghost price).

If i do a custom search that search menus with preu fantasma equal or lower than 16 or 9 or any ghost price, the custom search works perfect.

So... the problem is that custom search doesn't work with search of custom post type when I filter that custom post type by a field of repeteable group of that custom post type.

I need help to solve this.

Thanks in advance for your help.

#1565633

Nigel
Supporter

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

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

Unfortunately filtering by fields of repeatable field groups is not supported, it was never implemented.

I suggest you submit a feature request so that the product manager is aware of the demand.

What is supported is creating a search where the content is not the menu posts, but where you specify the prices repeatable field group as the content selection, and you can include filters for the fields which belong to that group.

But the query from this View returns the groups of fields, irrespective of the menu post they belong to.

You can output the menu the group belongs to in the results by using the Post Selection tab when inserting a shortcode with the Fields and Views button and specifying that the source post should be the parent of the repeatable field group.

I think it will help for you to understand if you simply try that and see what happens.

#1565689

Hi Nigel. Thanks for your answer.

I don't understand this:
--------------
What is supported is creating a search where the content is not the menu posts, but where you specify the prices repeatable field group as the content selection, and you can include filters for the fields which belong to that group.

But the query from this View returns the groups of fields, irrespective of the menu post they belong to.

You can output the menu the group belongs to in the results by using the Post Selection tab when inserting a shortcode with the Fields and Views button and specifying that the source post should be the parent of the repeatable field group.
-------------

Can You explain me this again with other words? - > You can output the menu the group belongs to in the results by using the Post Selection tab when inserting a shortcode with the Fields and Views button and specifying that the source post should be the parent of the repeatable field group. Is this like as country - cities?

#1565725

Nigel
Supporter

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

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

Screenshot 2020-03-27 at 15.05.58.png

Make a View where the content selection is your repeatable field group.

Include a search filter for the custom field you want to search by.

In the output section just insert the wpv-post-title shortcode to output the title. You'll note that it outputs the name of the group of fields (because that is what is being queried).

Using the Fields and Views button try inserting the post title again, and use the Post Selection tab to show the options for which post source to use (see screenshot).

The shortcode that is inserted will have an item attribute that specifies the shortcode should use something other than the current post in the loop as the source for the title.

When you do that it should be more clear what is possible.

#1565865

Ok Nigel. I understand now. You suggest me that I search by repeteable fields and I Show the name of menu related to that price, right?

But my custom search is searching menus by taxonomy of menu, other fields, city where is located the restaurant owner of menu, and price. So...your solution is not right. If i search only by price.. is right but I'm using others filters related to menus.

SO... your solution don't solves my search

#1565891

Nigel
Supporter

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

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

As I explained in my first reply, what you want to do is not supported, you cannot do it. You can only ask that the feature be added (which I note you have already done).

I was pointing out an alternative (inferior) option, but you cannot mix filtering by other fields and taxonomies belonging to menus with filtering of fields that are part of a repeatable field group, it's simply not possible (even if it is quite reasonable that you would expect to be able to do it).

Only if you remove the repeatable field groups and make the price fields belong directly to the menu posts can you include price in search filters.

Sorry that I don't have a solution for what you actually want to do.

#1565935

Hi Nigel. It's just that I was saying at the beginning about your suggestion -> To do the same like as related posts. Thanks for your suggestion and thanks a lot for your time, patience and help.

#1565937

My issue is resolved now. Thank you!

#1566083
Captura de pantalla 2020-03-27 a las 19.54.47.jpg
Captura de pantalla 2020-03-27 a las 19.54.34.png

Hi again Nigel.

It's possible to do my request, but with one relation but this rocks!

In the filter options there is a top button with that option. I attach 2 screenshots.

^_^

#1566115
Captura de pantalla 2020-03-27 a las 20.10.27.png
Captura de pantalla 2020-03-27 a las 20.10.37.jpg

It's not solved yet because I can't get the price

Ho can i render the the field that i attach in the screenshot?

#1567739

Nigel
Supporter

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

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

I can't see the details of the View from your screenshots (what post type is being queried, for example).

Can I get access to your site and look at your set up? Then I will be in a position to comment.

I will mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site.

Which is the View (or Views) I should be looking at?

#1568325

Nigel
Supporter

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

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

OK, thank you.

Your View queries the Menus post type, and so it will return Menu posts.

The post relationship filter you added lets you search for Menu posts that have a repeatable field group from a select list of names, but the query still returns Menu posts.

The "Preu del menu" custom field doesn't belong to the menu post type, it belongs to the repeatable field group, which is not the same thing.

A menu post cannot output a field from a repeatable field group because the field doesn't belong to it. To output the preu del menu custom field you must use a View that queries the repeatable field group.

I know that you really want it to work that you can search menus by the preu del menu field, but you cannot, because of a limitation in how repeatable field groups are implemented.

You have found that you can have a relationship filter but it doesn't actually help.

The only way that you can search/filter menu posts by the preu del menu custom field is if you make preu del menu directly belong to menu posts, and not be part of a repeatable field group.

I hope that one day we will improve this, and when we next review our main development priorities I will push for this to be worked on, but right now I'm out of things to say, other than to apologise once more that it is not possible.

#1568351

OK!

Thank you Nigel!