Forums Forums Search & Filter Pro if post meta datestamp is in future

Viewing 10 posts - 1 through 10 (of 10 total)
  • Anonymous
    #200140

    Hi there,

    For a website I created a filter with events. The events need to be in the future. So I want to check if the from date is after today. If so show results. If not check if the end date is after today, if not don’t show the event, if so show results.

    The from and end date are specified in the post meta of the posts. How can I configure this in the post meta tab?

    Trevor
    #200159

    It is not possible to do this in that tab. You would need to create some custom code to do this using this filter:

    https://searchandfilter.com/documentation/action-filter-reference/#edit-query-arguments

    Anonymous
    #201409

    Hello Trevor,

    I hope you can help me with the following:
    How can i prefill a datepicker field in the filter? I want to prefill it with the current date. Can i use the mentioned filter for that because we’ve tried multiple things but we can’t get it to work.

    Thanks in advance.

    Trevor
    #201413

    Would you need to change that date once set, or let the user change it?

    Anonymous
    #201418

    When i load the page, the page is not yet filtered and shows all the events (even in the past). We like to prefill the from date with the current date, so the results show current events. Then the user can edit the date as he likes

    Trevor
    #201434

    Ah, then that is a problem that cannot be resolved. Using the filter will allow you to set the value, but it will not affect the initial page load. Using JavaScript to do the same will then overwrite any selection made subsequently by the user. I am sorry, but what you want is not currently possible.

    Anonymous
    #201447

    It doesn’t have to be a JavaScript solution. I just need it to not show events in the past.

    Trevor
    #201451

    I understand. I have tried myself on one of my sites to do this, but it is not possible, sorry.

    Anonymous
    #201473

    Ok, so if I understand well the plugin does allow to render results on page load, but doesn’t allow to filter those results.

    What about the following:
    Is the sf_input_object_pre filter hook not called on page load? If it is, I could check if the ‘from data’ field is empty and if so I’d add the present date to the $input_object.

    Could this work?

    Thank you in advance

    Trevor
    #201482

    That filter is only called before a filter is applied, so, when you do the first search. I had expected it to do as you suggest, but when I tested it before, the form showed the value I set, but the results did not reflect this.

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