Custom Fields LIKE/EXACTLY LIKE options does not work

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Custom Fields LIKE/EXACTLY LIKE options does not work

This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 7 years, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #9525
    misha77
    misha77
    Participant

    http://dress-rentals.info/ – is a test site.
    I’m trying to filter my pages with cusom fields. I use Advanced Custom Fields plugin to create custom fields.

    And i noticed that when i coose in Ajax Search Pro LIKE and OR options it does not work how it should be…
    I give to may test page custom field SIZE and it is S, M, XL. But Ajax search still showing this page if i choose XS or L size.
    Please see the screenshots.

    I tryed to change theme, and to swich off all plugins.

    Attachments:
    You must be logged in to view attached files.
    #9531
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    Thank you very much for the details, it helped me a lot!

    The problem there is that the ACF checkbox is a complex field, and is stored as an Object in the database, not as a simple text field. Like so:

    a:3:{i:0;s:1:"L";i:1;s:2:"XL";i:2;s:1:"M";}

    So exact matching won’t work, as the whole text should be entered. The non-exact matching is not working because for example typing “L” matches this string even if only “XL” is selected, because it’s a substring of it.

    I have done some experiments and I have found a solution. To match any of these, the delimiters (double quotes) should be added to the values as well. In your case, you need to change them to:

    "XS"||XS
    "S"||S
    "M"||M
    "L"||L
    "XL"||XL
    "XXL"||XXL

    So basically encapsulate every value with the code of the double quote string aka:

    "

    This did the trick on my test environment, and hopefully for you as well 🙂

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.