Forums Forums Search & Filter Pro Set filter as default

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

    Hi guys, i created a page with filter + results shortcode. Is it possible to set one filter as default? so if you open that page it will automatically load that values?

    Anonymous
    #105919

    I need to set current-date (in a date field) as default so i can see “daily” elements only on page load. Thanks in advance for the help

    Trevor
    #105930

    You would have to do this with javascript. Here is an example that I have set up:

    <script type="text/javascript">
    jQuery( document ).ready(function($){
      var now = new Date();
      var today = ('0' + now.getDate()).slice(-2) + '/'
                 + ('0' + (now.getMonth()+1)).slice(-2) + '/'
                 + now.getFullYear();
      jQuery('li:first-child input[name="_sfm_my_acf_date_field[]"]').val(today);
      jQuery('li:last-child input[name="_sfm_my_acf_date_field[]"]').val('31/12/2050');
    });
    </script>

    This example snippet shows how to set the ‘from’ and ‘to’ dates for a field in acf called my_acf_date_field set up as a date range in SS&F Pro.

    The ‘from’ is set to today, ‘to’ is set to a specific date. Note that you have to get the date format right for your installation, the example above shows it in mm/dd/yyyy format.

    Anonymous
    #105943

    This doesnt’ solve the problem, it continuosly pass that value on each page of results

    Trevor
    #105945

    Ah. My usage was for a page that goes to a different results page. You would have to test if the field was empty (unset) before setting it.

    You might be able to do this using PHP, using the Edit Query Arguments filter. Test if that date is set, and if not, set it.

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