Forums › Forums › Search & Filter Pro › Set filter as default
Tagged: current, date, default fields
- This topic has 4 replies, 2 voices, and was last updated 7 years, 6 months ago by Trevor.
-
Trevor(Private) May 2, 2017 at 3:18 pm #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.
Trevor(Private) May 2, 2017 at 3:37 pm #105945Ah. 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.
-
AuthorPosts