Skip Navigation

[Resolved] Include custom field values in the general site search

This support ticket is created 2 years, 1 month 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
- 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/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by quentinN 2 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#2475343

Hello,
I notice that my custom fields (Wysiwyg in repeatable fields) do not appear in the native search-form of WordPress.

My repeatable Wysiwyg are in a post taxonomy, so I don't have access to edit this taxonomy natively to fill in "include to the search form".

Do you have a solution?

Here is an example:
When I search for "gym", I have no results here: hidden link
when in fact this word exists here: hidden link

#2475871

Hello,

I assume you are using Relevanssi plugin to setup the WordPress built-in search feature.

If it is, this is a limitation of Relevanssi plugin, see their document:
hidden link
1) You can only do this with Relevanssi Premium because the free version of Relevanssi can’t index taxonomy terms.
2) Relevanssi won’t index these taxonomy custom fields because taxonomy terms aren’t generally allowed to have custom fields
3) As a workaround, you can use the relevanssi_taxonomy_term_to_post filter, for example:
a) Use relevanssi_tax_term_additional_content filter hook to create a custom PHP function
b) In this PHP function:
- get assigned taxonomy terms:
https://developer.wordpress.org/reference/functions/wp_get_post_terms/
- Get the your custom taxonomy fields values, add those values into Relevanssi index
https://developer.wordpress.org/reference/functions/get_term_field/

#2475965

Hello,

Sorry but I don't use any plugin for search. It is the native one of WordPress that I would like to adapt to take into account the custom fields of Toolset Types.

Do you have another track?

Quentin

#2475993

No, there isn't such kind of built-in feature within Toolset plugins, you can follow our document to use Relevanssi plugin with Toolset plugins:
https://toolset.com/course-lesson/searching-texts-in-custom-fields-with-toolset-and-relevanssi/

Then use the workaround I mentioned above to include the term fields in the search

#2476071

I finally added a development by myself that queries the database to display the posts.
Thanks for your insights

Quentin