Skip Navigation

[Resolved] Text search for custom fields in repeatable group

This support ticket is created 4 years, 9 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.

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.

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+01:00)

This topic contains 3 replies, has 3 voices.

Last updated by Nigel 4 years, 9 months ago.

Assisted by: Nigel.

Author
Posts
#1299119

I have installed Relevanssi and add some custom fields,
But I think it's only work with single text type, It seem not work with number, phone, email type, and single text fields in repeatable group

#1300133

Waqar
Supporter

Languages: English (English )

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

Hi,

Thank you for waiting, while I performed some tests.

I'm happy to confirm that it is possible to index the fields in a repeating field group, through Relevanssi and here are the steps:

1. Suppose that you have a post type "Project" and it has a repeating field group "Project RFG" attached to it.

2. From the field group settings screen, you'll check the option "Include this field in text searches throughout the site" for all the fields which you'd like to be indexed.
( screenshot: hidden link )

3. Next, please go to WP Admin -> Toolset -> Settings -> Text Search and select all the fields which you'd like to be indexed and copy their slugs from the field below.
( screenshot: hidden link )

4. Now, go to WP Admin -> Settings -> Relevanssi -> Indexing and make sure that both the parent Project and its child Project RFG post types are selected.
( screenshot: hidden link )

5. On the same page, you'll select "some" for the "Custom fields" option and paste the slug of the copied custom fields from step 3 and then use the "Build the index" button on the top, to regenerate the search index.
( screenshot: hidden link )

6. In post view that you'll use for the search, you'll select both post types; "Project" and "Project RFG".
( screenshot: hidden link )

Important note: The search results will now include hidden "Project RFG" posts too, so to show your content in the loop item in a more meaningful way, you'll need to distinguish which type of post type is being shown and then show the required data accordingly.


[wpv-conditional if="( '[wpv-post-type]' eq 'project' )"]
Show this content if post type is Project
Title: [wpv-post-title]
[/wpv-conditional]

[wpv-conditional if="( '[wpv-post-type]' eq 'project-rfg' )"]
Show this content if post type is Project RFG
Title: [wpv-post-title item="@project-rfg.parent"]
[/wpv-conditional]

You can learn more about using conditional blocks and "item" attribute, from these guides:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
https://toolset.com/documentation/user-guides/views-shortcodes/item-attribute/

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

regards,
Waqar

#1303133

It's really work,
I want to show the result with project order ascending and project-rfg descending

#1303561

Nigel
Supporter

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

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

Hi there

Waqar is on vacation so I'll follow-up here.

From your last comment, you have working what Waqar described to include custom fields from the posts themselves and also from repeatable field groups belonging to the posts in the searches, is that correct?

And now you just need to know about changing the ordering?

If that's the case it is not possible to group the results by project.

The solution that Waqar proposed is a workaround to the problem that the initial question about including repeatable field group custom fields in the relevanssi search for some post type is not possible.

Waqar's solution works because the View queries for both the main post type and also the special hidden post type that is used to store the groups of repeatable fields, and the results of the query are a mix of the two post types.

You could add ordering rules, such as to order by the post date or by post title, but it would order *all* of the posts (from both post types) according to such a rule. And this would only work where you were filtering by some custom field or taxonomy. For text searches, as the notice in the Views admin declares, the ordering of the results will be controlled by Relevanssi, not by Views.

One last point, which is a clarification of something you discussed with Waqar. You can include and custom field types which store their data as text, they do not have to explicitly be text fields, so fields such as emails and even single select fields can be indexed by Relevanssi.

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