Reply To: ACF datepicker

#8953
Ernest Marcinko
Ernest Marcinko
Keymaster

Hi!

To answer your second question first: I think you are looking for the custom field filters: https://goo.gl/6dKjaP
You can basically create filters based on custom fields with that, including ACF date field. Please note however, that the ACF date picker filter will only work if the default storage method is used with ACF dates, the default “20160501” as you mentioned in your first post. Otherwise the search won’t be able to compare the values.

And I answered your second question first, because this might lead to a catch 22 situation. Because the search date picker filter only works with the default ACF date storage format (20160501), if you choose to this filter, you won’t be able to use the same custom field to search the way you want it, as the data has to be stored in that format.
In case you want to use the custom field date search filter and search within the date custom field, I recommend creating 2 separate date fields:
– one with the ACF default date format to used within the filter
– second for searching the dates in any format you desire
I know it sounds silly and all, but I can’t think of any better solution right now.

Now, to finally answer your first question:

I understand what you want now. You need to match the date field exactly from it’s beginning, so:

– “2016” should not match “01/06/2016
– “01/06” should match “01/06/2016″ (because it begins with it)

Am I correct?

Unfortunately that is not how the plugin works. I would rather not go into details why, it’s a very complicated issue, but I think I can offer you a solution, but you will have to modify one of the plugin files.

I’m assuming you use the regular engine and the “or” keyword logic (defaults):
0. Before any change, make sure to have a full site back-up, in case anything goes wrong.
1. Open up the ajax-search-pro\includes\classes\search\search_content.class.php and scroll to lines 540-546, where you should see this:

2. Change those lines to:

The difference between these two is that the second does not have a wildcard on the beginning of the query, thus allowing to match strictly from the beginning.

I hope this covers everything you wanted to know.

Best,
Ernest Marcinko

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