Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Search by date range with custom fields datepicker
- This topic has 3 replies, 2 voices, and was last updated 9 years, 2 months ago by
Ernest Marcinko.
-
AuthorPosts
-
March 22, 2017 at 2:06 pm #12413
patriziord
ParticipantHi,
following your documentation here – https://goo.gl/T442YK – I’m building a search by date range for a travel agency.
What I’ve done:
1
created two custom fields using ACF pro 5, datepickers, with the following settings
“data inizio” – for the start date
“data fine” – for the ending date
each field has been set with the Return Value * format yymmdd2
created three posts, setting each with different values onto my custom date fields3
set your plugin in General Options in order to
Search in posts
Search in custom post types (drag the acf-field-group and acf-field to the right)
search in selected custom fields (drag my two custom fields to the right)set up Frontend Search Settings options to use my custom fields, data inizio to show results after the date, data fine to show results before the date.
The issue:
I can’t get any resultWhat I found so far:
the plugin panel description for this scenario – see image http://imgur.com/a/pIyfS – looks valid up to ACF version 4 – see ACF 5 documentation here – https://goo.gl/aO8dn2
Previous versions of ACF contained a setting called ‘Save Format’ allowing the developer to change the format saved in the DB. This setting has been removed in favor of a set format of ‘YYYYMMDD’.
Please note that the value is always saved as YYYYMMDD in the DB.Also:
taking a look into my DB the meta_value stored by ACF looks always like this – http://imgur.com/a/dlqGQ – in a longtext cell. Not a YYYYMMDD format.How could I make this work?
If the issue is just a matter of updating the way your plugin retrieves dates,
is it feasible to make a hard coded change in your code, while waiting for a upgrade – your help strongly needed 🙂 .If the issue is also / only about the way ACF stores the datepicker values, should I ask them as well?
Or, in your opinion, is it possible the different date format – YYYYMMDD in documentation, the other one in my DB – is caused by some server settings of mine? Maybe PHP / MySql version.Thanks in advance.
Patrizio
March 22, 2017 at 3:18 pm #12414Ernest Marcinko
KeymasterHi Patrizio,
Your configuration looks correct, looks like ACF simply switched to a MySQL datetime field. Luckily this is very simply fixable, by changing the field type to MySQL datetime: http://i.imgur.com/U1NoJVm.png
I’ve made the change on your search instance, and tried to pick a few dates, and it appears to be working correctly now.
March 22, 2017 at 3:43 pm #12415patriziord
ParticipantI was ready for some dark ride because of those premises.
I’ve been lucky with that configuration, you’re awesome as usual, it was time to leave my review on Codecanyon.
Thank you so much Ernest!Cheers,
PatrizioMarch 23, 2017 at 1:49 pm #12426Ernest Marcinko
KeymasterYou cannot access this content.
-
AuthorPosts
- The topic ‘Search by date range with custom fields datepicker’ is closed to new replies.