Skip Navigation

[Resolved] search terms in custom field

This thread is resolved. Here is a description of the problem and solution.

Problem:
search terms in custom field

Solution:
To search text within custom field and taxonomy, there is a relevanssi integration:
=> https://toolset.com/course-lesson/searching-texts-in-custom-fields-with-toolset-and-relevanssi/

You can find the proposed solution in this case with the following reply:
https://toolset.com/forums/topic/search-terms-in-custom-field/page/2/#post-2000521

Relevant Documentation:

This support ticket is created 3 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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 19 replies, has 2 voices.

Last updated by davidm-13 3 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#1998445

Hi I have a custom field in a child post that describes medicinal complaints. I need to input terms (eg. "runny nose", "backache") and then search all the medical complaints for those terms and return the title of the parent post of those complaints.
How would I construct the view for such a query?
Thanks for any help

#1998579

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please tell me how you setup your custom field in child post type. Is it a select field or normal single field or it's a repeating single field?

Also, you say you want to search the term, how exactly you want to search the term, do you want to prefilter the result or you want to allow the user to input or select the term?

#1998659
complaint-use-tax.JPG
complaint-use-cf.JPG
complaint-use.JPG

Hi Minesh, Thanks for your help.
Here's a couple of screenshots of the field
I have it as a custom field in the child post - complaint-use-cf, complaint-use and the same content as a taxonomy - complaint-use-tax.
I'd like the user to be able to enter several words or a phrase to search for eg. stomach cancer, "sore throat".
Thanks

#1998697

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Do you mean that you are coping the value of selected term name to the custom field "complaint-use-cf" you created.

What if you create a view and try to add the frontend filter for your custom field and in the view output display the related parent post.

More info:
=> https://toolset.com/course-lesson/creating-a-custom-search/

#1998713

Hi Minesh,
I setup and populated the complaint-use both as a custom field and a taxonomy 'cause I wasn't sure of the best/easiest way to search. Appreciate any code snippets for your suggestion to create a view (especially how to look for words or phrase in complaint-use), and add a frontend filter. Will also check the link.
Thanks

#1998759

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Regarding how you can create custom search, you can check the following link:
=> https://toolset.com/course-lesson/creating-a-custom-search/

To search text within custom field and taxonomy, there is a relevanssi integration:
=> https://toolset.com/course-lesson/searching-texts-in-custom-fields-with-toolset-and-relevanssi/

There is no code snippet you need to add, you need to create view with text search filter. I suggest you should go throw the above link step by step and let me know if you will require further help.

#1998881

Thanks Minesh, exactly what I needed will go through as you suggest.
One question the output - parent title - needs to be unique, several child posts may return the same parent, I need the parent title to appear once in the output, any advice how to do this?

Thanks

#1998893

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

For that we can use the View's hook and that is another question.

Lets fix the issues one by one. Can you please first create your search, once that is setup and working, we will try to address your group by parent title question.

#1999785
complaint-plant-search1.JPG

Hi Minesh,
I've followed the relevanssi integration and installed the indexes, and created the custom search.
I'm not seeing any search results. Haven't specified parent post title for output
Would like this view to output a list of (unique) parent post titles on a separate page.
the view code is:

[wpv-filter-start hide="false"]
[wpv-filter-controls]
<div class="form-group">
	<label for="wpv-post-search" class="label-right">[wpml-string context="wpv-views"]Medical Complaint / Use[/wpml-string]</label>
	[wpv-filter-search-box output="bootstrap"]
    [wpv-filter-submit name="Search"]
</div>
[/wpv-filter-controls]
[wpv-filter-end]

The screenshot's the Custom Search Settings

#2000161

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please send me problem URL where you added your view as well as what view you created with search box?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2000235

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

It seems you forget to share the problem URL where you added your view. Can you please share that.

#2000307

It's the home page - florapalaestina-ethnobotany.org right side column

#2000313

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

After login to admin, I found that you are using outdated Toolset plugins. We always recommend running your site with the latest stable release plugin version.

*** Please make a FULL BACKUP of your database and website.***
Could you please update ALL Toolset plugins to it's latest officially released version. You can download the latest plugin release from your accounts page OR you can update it from your plugins page.
=> https://toolset.com/account/downloads/

#2000319

Updated Toolset plugins

#2000427

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please tell me what is your target page where you want to display your search results?