Skip to content

Instantly share code, notes, and snippets.

add_filter( 'facetwp_facet_orderby', function( $orderby, $facet ) {
if ( 'trajects' == $facet['name'] ) {
$ordered_terms = '"traject-4", "traject-3", "traject-2", "traject-1"';
$orderby = 'FIELD(f.facet_value, $ordered_terms)';
}
return $orderby;
}, 10, 2 );
@andrewmcnaughton
andrewmcnaughton / gist:b082c056c52ba3d8d59a2bf4885dcce1
Created November 1, 2018 15:28
Order by Month if this year, otherwise only show year (but also in order)
Current code:
add_filter( 'facetwp_index_row', function( $params, $class ) {
if ( 'date' == $params['facet_name'] ) { // change date_as_year to name of your facet
$raw_value = $params['facet_value'];
$today = strtotime(date( 'Y' ));
$screeningDate = date( 'Y', strtotime( $raw_value ));
$screeningDateYear = strtotime($screeningDate);
{
"convert_path" : "/usr/local/bin/convert"
}