Custom datepicker

This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 4 years, 5 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #25971
    baumelerch71
    baumelerch71
    Participant

    Hi

    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
    Stefan

    #25975
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi 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.

    Best,
    Ernest Marcinko

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


    #26002
    baumelerch71
    baumelerch71
    Participant

    Hi 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
    Stefan

    #26005
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi 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.

    Best,
    Ernest Marcinko

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


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.