Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created March 5, 2019 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/4dbb6f9938d747d7e2a19af6d8f39274 to your computer and use it in GitHub Desktop.
Save billerickson/4dbb6f9938d747d7e2a19af6d8f39274 to your computer and use it in GitHub Desktop.
<?php
/**
* FacetWP, Filter by Year
*/
add_filter( 'facetwp_index_row', function( $params, $class ) {
if ( 'filter_by_year' == $params['facet_name'] ) {
$raw_value = $params['facet_value'];
$params['facet_value'] = date( 'Y', strtotime( $raw_value ) );
$params['facet_display_value'] = $params['facet_value'];
}
return $params;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment