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!
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
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,
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.
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,