FacetWP create a month/year facet

<?php

/**
 * Create a facet with Post Date (or any other date field)
 * Re-index after adding or updating this filter
 * For more options and/or using months or years only, see: 
 * https://facetwp.com/help-center/developers/hooks/indexing-hooks/facetwp_index_row/#create-a-month-year-facet
 */
add_filter( 'facetwp_index_row', function( $params, $class ) {
	if ( 'date_as_month_year' == $params['facet_name'] ) { // change date_as_year to name of your facet
		$raw_value = $params['facet_value'];
		$params['facet_value'] = date( 'Y-m', strtotime( $raw_value ) ); // Use "2023-11" for the facet choice in the URL
		$params['facet_display_value'] = date( 'F Y', strtotime( $raw_value ) ); // Use "November 2023" as display value
	}
	return $params;
}, 10, 2 );