Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Custom datepicker
- This topic has 3 replies, 2 voices, and was last updated 6 years, 3 months ago by
Ernest Marcinko.
-
AuthorPosts
-
February 24, 2020 at 4:09 pm #25971
baumelerch71
ParticipantHi
I’m building a website for a travelsagency where we import the data with an api from an external tool into custom fields in wordpress.
Because we have some trips with multiple departure dates we have to “jason_encode” them to use in custom fields. Giving us this:
[{“abfahrt”:”2020-06-07″,”rueckkehr”:”2020-06-14″},{“abfahrt”:”2020-06-28″,”rueckkehr”:”2020-07-05″},{“abfahrt”:”2020-07-26″,”rueckkehr”:”2020-08-02″}] (abfahrt = departure, rueckkehr = return).
We would like to implement a datepicker for the searchresults, to choose all dates after a specific one. Obviously in this format that’s not going to work, since we don’t have a single date. Is there a way to make it work though? What could you rocommend us to do?
If there is nothing out of the box, would you custom code that, how long would that take and how much would it cost?Thank you and kind regards
StefanFebruary 24, 2020 at 4:17 pm #25975Ernest Marcinko
KeymasterHi Stefan,
I would probably recommend extracting the required single date from the JSON data, and added into a different custom field. I think that would be the simplest possible solution. Probably hooking that to the import process, so it take care of it automatically.
Unfortunately we are not available for custom coding, but we can recommend either wpkraken, or individual developers on Envato Studio.
February 26, 2020 at 8:02 am #26002baumelerch71
ParticipantHi Ernest
Thanks for the quick answer.
I have another question regarding the filtering.
I have a dropdown filter for a custom field from which I want to exclude one value. I used that value for testing only and no post contains it anymore, but it’s still present in the filter.
Is there a way to exclude specific values or do I have to manually include any value I want? The later wouldn’t be so great though, since it’s possible that it changes in the future.Thanks and kind regards
StefanFebruary 26, 2020 at 9:57 am #26005Ernest Marcinko
KeymasterHi Stefan,
If the value is displayed, then it is still present in the wp_postmeta database. Make sure to clean that up, and it will disappear.
Alternatively, you can use a custom code to remove a specific value from a filter. Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!
add_filter('asp_pre_get_front_filters', 'asp_change_a_filter', 10, 2); function asp_change_a_filter($filters, $type) { $exclude = array('value1', 'value2'); foreach ($filters as $k => $filter) { if ( $type == 'custom_field') { $filter->remove($exclude); } } return $filters; }You can add any number of values that you want to exclude from the list to the $exclude variable array.
-
AuthorPosts
- You must be logged in to reply to this topic.