Skip Navigation

[Resolved] Use Text search for Custom Fields by adding info to the body of the post

This support ticket is created 6 years, 7 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
- 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 7 replies, has 2 voices.

Last updated by Luo Yang 6 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#565286

I'm trying to use the toolset search for listings with certain field values (for example _listing_city = Denver) and have the view display the results of the search. I understand that the toolset views search only searches the content and the title of a post but if I could insert the custom field values into the content of the post then it would be indexable right? The problem is when I add fields to the content template they are not technically part of the content of the post (or the search is just ignoring that particular part of the content). so is there a way that I can put that info into the content so that it can be indexed in my search?

#565407

Dear chance,

Yes, it is possible with Relevanssi plugin+ Views plugin, see our document:
https://toolset.com/documentation/user-guides/searching-texts-custom-fields-views-relevanssi/

section "Including custom fields in the search"

#566002

The fields I'm searching for are not types fields there from another plugin so I can't check the use in custom search box

#566266

You can try to convert this custom field under Types control, see our document
https://toolset.com/faq/how-do-i-convert-existing-custom-types-and-fields-to-types-control/
section "Converting custom fields"

#566800

The fields are not listed in there. All of the fields start with _listing_ so they could be hidden?

#567023

Yes, you are right, it is expected result, Types plugin can not control those hidden field, which field slug starts with "_". If you agree, we can take it as a feature request. our developers will evaluate it.

#567168

Yes, that should be a feature, but is there any workaround for the meantime. Is there any way I could make types filed have the same value as the hidden field like _listing_price = listing_price or something like that?

#567412

It is not recommended to use Types plugin to control or make the hidden field, it will conduct other unexpected problems, you can check the source code of Types plugin, file "types\library\toolset\types\embedded\classes\field\definition_factory_post.php", line 31~3:

		$meta_keys = $wpdb->get_col(
			"SELECT meta_key FROM {$wpdb->postmeta} GROUP BY meta_key HAVING meta_key NOT LIKE '\_%' ORDER BY meta_key"
		);

As you can see, we avoid to display those hidden fileds in the "Post Field Control" page.

And there isn't such a built-in feature with Types plugin:
"have the same value as the hidden field like _listing_price = listing_price"

But you can try with wordpress built-in action hook "save_post" to achieve what you want:
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post
For example, when a user edit a post, use action hook "save_post" to trigger a PHP function, in this PHP function, do these:
1) get the custom filed "_listing_price" value
https://developer.wordpress.org/reference/functions/get_post_meta/
2) Save it to another field "listing_price"
https://developer.wordpress.org/reference/functions/update_post_meta/

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