Date picker customization

The plugin builds its date filters with the Date Range Picker library. Before each date picker is created, the plugin passes its options to an optional function, a_w_f.filter_daterangepicker_options. Define this function to change any of the Date Range Picker options: limit the selectable dates, hide the month and year dropdowns, change the button labels, and so on.

Example: allow only dates in November 2025
var a_w_f = typeof( a_w_f ) === 'undefined' ? {} : a_w_f;

a_w_f.filter_daterangepicker_options = function( $daterangepicker, daterangepicker_options ) {
	daterangepicker_options.minDate = '01/11/2025';
	daterangepicker_options.maxDate = '30/11/2025';
	daterangepicker_options.showDropdowns = false;

	return daterangepicker_options;
};

Notes:

  • $daterangepicker is the date filter’s input field, as a jQuery object.
  • daterangepicker_options holds the options the plugin has prepared for that filter: the date format, the selected dates, the Clear button label and others. Change only the options you need.
  • The function must return the options object.
Things to keep in mind
  • Use the filter’s date format. Date filters use DD/MM/YYYY, so 01/11/2025 is 1 November 2025. Filters with the time picker enabled use DD/MM/YY HH:mm. If your site has both kinds, pass dates as moment.js objects, which work with either format:
daterangepicker_options.minDate = moment.utc( '2020-06-01' );
daterangepicker_options.maxDate = moment.utc( '2020-06-30' );
  • Don’t replace the locale object. It holds the plugin’s date format and the Clear button label. Change single properties instead, for example daterangepicker_options.locale.applyLabel = 'OK';.
  • The function applies to every date filter. To change only one of them, check its input field. You can find it in your browser’s inspector, its id will end in -daterangepicker.
if ( 'your-filter-id-daterangepicker' === $daterangepicker.attr( 'id' ) ) {
	daterangepicker_options.showDropdowns = false;
}
Where to add the code

Add the code to any regular script on the pages with the filters: your child theme’s JavaScript file, annasta Filters > Plugin Settings > Custom JavaScript field, or a code snippets plugin. The script must not be loaded as defer or async. The plugin creates the date pickers when the page has finished loading, and your function has to be defined by then.