Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
License

Feature Request – Filtering Dates

I have a column displaying an ACF date field.

The dropdown for filtering shows “All Reservations” and then each possible date. It would be nice if under “All …” the first option was “Today” so select today’s date instead of my having to look it up and select it.

6 years, 2 months ago
Stefan van den Dungen Gronovius
Developer

Thanks for your request.
At this moment, most of our date columns, including the ACF date column have the following filtering methods:
– Daily
– Monthly
– Yearly
– Future / Past
– Range

Another method that only displays for today is too specific so not really an options in my option.
But if you use the daily dropdown, you could use one of our filters to put alway a ‘Today’ option on top of the filter dropdown. You could use the following snippet in your own code to put the ‘Today’ option to the default dropdown.

/**
 * Hide empty option from filter menu
 *
 * @param array     $args
 * @param AC_Column $column
 *
 * @return array
 */
function acp_filtering_show_today_date_label( $args, $column ) {

	if ( $column instanceof ACA_ACF_Column && 'date_picker' === $column->get_acf_field_option( 'type' ) ) {
		unset( $args['options'][ date( 'Ymd' ) ] );

		$args['options'] = array_merge( array(
			date( 'Ymd' ) => 'Today',
		), $args['options'] );

	}

	return $args;
}

add_filter( 'acp/filtering/dropdown_args', 'acp_filtering_show_today_date_label', 10, 2 );
6 years, 1 month ago

You must be logged in to reply to this topic.