djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php

add_filter( ‘facetwp_index_row’, function ( $params, $class ) {
if ( ‘fecha’ == $params[‘facet_name’] ) {
$date = $params[‘facet_display_value’];
$months_en = array( ‘January’, ‘February’, ‘March’, ‘April’, ‘May’, ‘June’, ‘July’, ‘August’, ‘September’, ‘October’, ‘November’, ‘December’ );
$months_es = array( ‘enero’, ‘febrero’, ‘marzo’, ‘abril’, ‘mayo’, ‘junio’, ‘julio’, ‘agosto’, ‘septiembre’, ‘octubre’, ‘noviembre’, ‘diciembre’ );
$date = str_replace( $months_es, $months_en, $date );
$date = date_create_from_format(‘j M, Y’, $date);
$date_formatted = date_format($date, ‘Y-m-d’);
if ( !empty( $date_formatted ) ) {
$params[‘facet_value’] = $date_formatted;
$params[‘facet_display_value’] = $date_formatted;
} else {
$params[‘facet_value’] = ”; // skip indexing
}
}
return $params;
}, 10, 2 );
{{/gist}}