Forums Forums Search & Filter Pro Date ranges with Search & Filter Pro and Events Manager

Tagged: , ,

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

    Hi,

    I’m developing an events listing here:

    http://bollandlowe.net/dev/watford/visit/whats-on/

    It uses Events Manager, and Search and Filter Pro to filter the listing. The category filtering and search is working fine, but I’m having a problem with date ranges.

    I saw your other posts about the incompatibility between how Events Manager saves dates and how S&F works with them, and wrote this hook:

    
    // Convert Events Manager dates yyyy-mm-dd to yyyymmdd and save to an ACF field, for Search & Filter Pro to use
    
    function save_event_meta( $post_id ){
    
    if (get_post_type($post_id) == 'event'):
    
    $filter_event_start_date = date("Ymd", strtotime(get_post_meta($post_id, '_event_start_date', true)));
    $filter_event_end_date = date("Ymd", strtotime(get_post_meta($post_id, '_event_end_date', true)));
    
    update_field( 'filter_event_start_date', $filter_event_start_date , $post_id );
    update_field( 'filter_event_end_date', $filter_event_end_date , $post_id );
    
    endif;
    
    }
    add_action('acf/save_post', 'save_event_meta', 20); // run before ACF saves the $_POST['fields'] data
    

    This converts the start and end dates from yyyy-mm-dd to yyyymmdd and saves them to fields. Numerical sorting based on this start date field works.

    However, when I try to do a date range filter it doesn’t return any results. I’m at a bit of a loss, and was wondering if it’s because the querystring the datepicker creates is in a different format?

    Any suggestions would be appreciated.

    Thanks!

    Trevor
    #220916
    This reply has been marked as private.
    Anonymous
    #220929
    This reply has been marked as private.
    Trevor
    #220993
    This reply has been marked as private.
    Trevor
    #221096

    Hi Joe

    I have looked at this again, and still cannot see an issue with what you have done. If you put WordPress into debug mode, does it output any errors? Does your server log any PHP or MySQL errors?

    Anonymous
    #221105

    Hi,

    I’ve set define( ‘WP_DEBUG’, true ); now in wp-config.php. Does that help?

    I can’t see any error log files when I look on the server, but I can ask the host’s support team.

    Trevor
    #221109

    If no error messages appear on the page, that means WordPress seems happy, so next check with the host to see if PHP and SQL error logging are on, and if so, to where?

    Anonymous
    #221182

    The host says there are no errors coming up in their logs.

    Do you have any other suggestions? If not we can carry on using it elsewhere in the site but will need to do something else for events.

    Thanks for your help on this.

    Trevor
    #221186

    The only other thing I can think of is that the events post type is somehow oddly defined by that plugin.

    Anonymous
    #221188

    OK, I think we’ll probably have to do events differently then.

    Thanks

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