This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

ACF date filter not working as expected

Home Forums Product Support Forums Ajax Search Pro for WordPress Support ACF date filter not working as expected

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #53657
    David CranleyDavid Cranley
    Participant

    Hi,

    We are using an ACF custom field publication_date as a date filter, but they aren’t functioning as expected.

    The link is: https://env-fmsbsite-redev.kinsta.cloud/publications.

    In other words, the “to” option displays Publications from after the selected date as well, and the “from” date Publications from also before the date selected. Some kind of filtering happens, because no longer all the Publications display, but it’s definitely not the right filtering.

    We have carefully reviewed the settings, but cannot figure out why this may be.

    Thank you in advance for your guidance.

    #53659
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

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

    It seems like there might be some sort of an unknown bug – when both filters are selected, it works. For now I have set relative values to both filters to make it work, but I would like to debug this issue more. I suspect it has to do something with the empty value on the second filter, somehow overriding the first due to the same field name.

    I tried to log-in via (s)FTP, but it does not authenticate, can you please check that?

    #53663
    David CranleyDavid Cranley
    Participant

    Thank you for the quick reply. We’ve updated the SFTP access notes with the port, that may be it. Double-checked the other values, they are correct.

    #53664
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Thank you, it works. I will do a bit of debugging now, don’t get scared if you see some weird output 🙂

    #53665
    David CranleyDavid Cranley
    Participant

    Got it. Thank you. 🙂

    #53666
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Okay, I have found the issue, it is however not related to the search.

    The filters were working fine, which I found strange, so I started checking the actual values of the publish_date field and found the culprit.

    The issue is that some values of that field are stored as timestamps and some values are stored as ACF dates. If you take a look at these debug outputs, in this one the ACF date values are stored, but on other entries (I guess older entries) the timestamp is stored.

    I suspect this field was imported and the data types are not matching with the current ACF date type. The only way to resolve this is to convert the incorrect timestamp data to ACF date data type. (especially if you want to use ACF date field) For display purposes it’s fine, ACF and Ajax Search Pro can both convert them, but for searching it is a massive issue, as there is no way to query on both at the same time, the data types must be the same.

    #53667
    Ernest MarcinkoErnest Marcinko
    Keymaster

    I forgot to add, I think if you simply open and save the old publication without changing them, the values get automatically converted by ACF. So if there is only a few old publications, that’s the easiest and fastest fix.

    #53668
    David CranleyDavid Cranley
    Participant

    That all makes perfect sense, thank you for spotting that. Yes, the values were indeed imported. We’ll take some time in a bit to manually update them, and will confirm it is then fixed.

    #53669
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Sure, let me know 🙂 It should do the trick, I see no other issues there.

    #53670
    David CranleyDavid Cranley
    Participant

    That did do the trick. Thank you very much!

    #53678
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Great!

    If you don’t mind, I will close this topic soon and mark it as resolved, feel free to open another one if you have other questions or issues.

    If you like the plugin and have not rated already, feel free to leave a rating on the wordpress plugin repository, it’s greatly appreciated.

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.