Forums Forums Search & Filter Pro Sort by ACF Date Time Events

Viewing 5 posts - 1 through 5 (of 5 total)
  • Anonymous
    #89721

    Hi,

    I’m trying to create events functionality to a site I’m building. I’m using the newest version of ACF Pro and Search & Filter Pro.

    I have two fields which should be the basis of how events are displayed in the results page: date_start and date_end.

    I would like to add this functionality to the search form:

    Upcoming events – Display all events ordered by date_start, exclude events where date_end >= $current_date.

    Old events – Display all events ordered by date_start, exclude events where date_end <= $current_date.

    Choose month – Display all events ordered by date_start in chosen month.

    I’m having trouble while testing this and searched around on the forums. I came over a post where Trevor said that the fields should be saved in yymmdd, but this is not how ACF saves date time fields to the database. Ex of saved db-entry: 2017-01-30 14:00:00.

    Doing a simple sort order test (see screenshot) does nothing (normal post dates work):

    Screenshot of sort order test

    Anonymous
    #89724

    Manually changing the URL gives me the correct results:

    From ?sort_order=_sfm_dato_start+asc+num to ?sort_order=_sfm_dato_start+asc+date and ?sort_order=_sfm_dato_start+desc+num to ?sort_order=_sfm_dato_start+desc+date

    But I can’t actually choose these options in the “Sort Type” dropdown.

    Trevor
    #89803

    I am not sure S&F Pro supports datetime fields, only date fields. Might that be the issue?

    Anonymous
    #89936

    ACF Pro only has a Date Time Field (It has a time field, but it does not have a simple Date field).

    I believe the actual problem is that the plugin does not allow Sort Type -> Date (which is a standard WordPress meta sorting value). When I changed the URL (see my previous post in this topic), the sort order corrected itself, but I cannot actually choose this in the plugin.

    Sort Order UI

    Initial Sort Order

    Trevor
    #89957

    My copy of ACF Pro does not have date or datetime fields, only jQuery Datepicker. What version do you have?

    The jquery datepicker stores the date as a number, hence a number sort works.

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