Skip Navigation

[Resolved] Apostrophe in field doesn't work in search

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/Karachi (GMT+05:00)

This topic contains 4 replies, has 2 voices.

Last updated by rubenM-3 2 years ago.

Assisted by: Waqar.

Author
Posts
#2506801

Hi,
I've got a field that contains some values with apostrophe, like "Caldes d'Estrac". This field is used in a Custom Search, but returns no posts. Field's name is Població, and page is hidden link. Filter is

Select items with field:
Rang Capacitat is a string equal to URL_PARAM(wpv-wpcf-rang-capacitat)
AND
Filter based on the frontend search filter by Població

Thanks!

#2507367

Hi,

Thank you for contacting us and I'd be happy to assist.

I've tested the "Població" field on the page and it seems to be filtering the results, based on the selected option.
( screenshot: hidden link )

Can you please share the exact steps to see how or when this search field fails?

regards,
Waqar

#2507493

Hi Waqar,
most of values, like "Alella" work. But there is a value, "Caldes d'Estrac", that doesn't work, I suppose that caused for the apostrophe.

Thanks,

#2508183

Thanks for writing back.

I see in the field group settings that the "Població" select field's options are set to store the text values (including special characters and spaces), which is not a very efficient or safe approach.
( screenshot: hidden link )

While you can use this type of text for the "Display text", for the raw custom field values that will be stored in the database, it is better to use the numeric values (e.g. 1, 2, 3, 4, 5, ...... ). It has performance benefits as well as, avoids any escaping issues due to special characters.

I'll recommend changing all values in the field's "Custom field content" column to numbers and then updating all existing "Ubicacions" posts once so that the new custom field values can be updated in the database.

After that, the search won't be affected by special characters like apostrophes.

#2508189

Hi Waqar, I see this was a mistake I did when creating the field, because I had a database with cities' names, and it was easier to do the import. I'll change field values, and then enter at all posts, and save them.

Thanks,