Skip Navigation

[Closed] search number filter not working properly

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.

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 1 year, 4 months ago.

Author
Posts
#2527991
2023-01-05_12-57-11.png
2023-01-05_12-57-21.png

when i type 999 it wont find the result
it requires to write exactly the correct number
see screenshot

#2528305

Nigel
Supporter

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

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

That's correct. You are filtering a single numeric field; when a user provides a number to filter by, the query looks for posts with a field that has that same value.

For partial matches you would use a text search field (and to include custom fields rather than just the post title and content in the search fields you would need to add Relevanssi to your site).

One option, to continue using a filter for the numeric field specifically, would be to use the API filter wpv_filter_query to modify the query arguments, to change the comparison from '=' to 'LIKE' (and wrap the filter value in % so that the generated query looks something like 'meta_value' LIKE "%999%" in your example).

See
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
https://developer.wordpress.org/reference/classes/wp_query/#custom-field-post-meta-parameters

The topic ‘[Closed] search number filter not working properly’ is closed to new replies.