Skip Navigation

[Resolved] Relevanssi indexing a field in a repeatable group?

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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Author
Posts
#2480751

We are adding Recipes to a site, and in order to help make sure that the results are WCAG compatible, we are asking admins to enter the ingredients as a repeated set of two single fields in a repeatable group called "ingredient":
"ingredient-amount" and "ingredient-description"
so that we can force the output into proper visual formatting and maintain compliance.

When I click the check box to "include in search results for "ingredient-description"", the field name in the toolset panel that I'm asked to include in Relevanssi is simply "wpcf-ingredient". Adding this to relevanssi basic does not seem to work. I have also tried "wpcf-ingredient-description" which does not work.

Relevanssi premium states that "fieldname_%_subfield" would work for ACF plugin. I have not used Relevanssi before, but it makes sense to me that a method like this would be needed - but based on their documentation, I'm not confident it would actually work for Toolset, since the "ingredient" group is stored as a "child post" rather than the actual post.

I am also happy to modify the search function, as I *only* need the search tool to return "recipes that have this in either their title or an ingredient description", but to be honest, figuring out the correct JOIN logic is a little complicated for me, I'm not a DB admin by trade.

tldr; How do I get my search box to consider all ingredient-description entries and return those recipes ?

#2482285

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

Each repeatable field group is stored as a separate post type. For example, if you have the primary post type "Recipe" which has a repeatable field group named "Ingredient", you have two custom post types, not one.

1. "Recipe" post type will hold all the main post type entries and any custom fields which are directly attached to this post type (i.e. not inside a repeatable field group), will be saved with this post type.

2. "Ingredient" post type will be a hidden post type that will hold all the entries that were created as the repeatable field group items. And any custom fields which are part of the "Ingredient" repeatable field group will be saved with this post type and not with the "Recipe" post type.
(in the backend the "Ingredient" posts will be connected to their parent "recipe" post through a post-relationship)

Based on this, if you'd like to perform an ingredient-based search, you'll need to create a view for the "Ingredient" post type and not for the "Recipe" post type, because the relevant ingredient custom fields are stored with that post type. In the view's results, you can always show the title of the parent "Recipe" post that a particular "Ingredient" post belongs to.

In the Relevanssi settings, you'll make sure that the "Ingredient" post type is enabled for the indexing. Toolset's custom fields just need to be entered with the prefix "wpcf-" and other than that, no special format is needed.
( ref: https://toolset.com/course-lesson/searching-texts-in-custom-fields-with-toolset-and-relevanssi/ )

I hope this helps and please let me know if you need any further assistance with this.

regards,
Waqar

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.