Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › ACF date filter not working as expected
- This topic has 10 replies, 2 voices, and was last updated 1 year, 1 month ago by
Ernest Marcinko.
-
AuthorPosts
-
April 10, 2025 at 1:50 pm #53657
David Cranley
ParticipantHi,
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.
-
This topic was modified 1 year, 1 month ago by
David Cranley.
April 10, 2025 at 2:23 pm #53659Ernest Marcinko
KeymasterHi,
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?
April 10, 2025 at 2:46 pm #53663David Cranley
ParticipantThank 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.
April 10, 2025 at 2:48 pm #53664Ernest Marcinko
KeymasterThank you, it works. I will do a bit of debugging now, don’t get scared if you see some weird output 🙂
April 10, 2025 at 2:50 pm #53665David Cranley
ParticipantGot it. Thank you. 🙂
April 10, 2025 at 3:11 pm #53666Ernest Marcinko
KeymasterOkay, 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.
April 10, 2025 at 3:18 pm #53667Ernest Marcinko
KeymasterI 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.
April 10, 2025 at 3:19 pm #53668David Cranley
ParticipantThat 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.
April 10, 2025 at 3:20 pm #53669Ernest Marcinko
KeymasterSure, let me know 🙂 It should do the trick, I see no other issues there.
April 10, 2025 at 4:18 pm #53670David Cranley
ParticipantThat did do the trick. Thank you very much!
April 11, 2025 at 8:44 am #53678Ernest Marcinko
KeymasterGreat!
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.
-
This topic was modified 1 year, 1 month ago by
-
AuthorPosts
- You must be logged in to reply to this topic.