Skip to content

BeAPI/facetwp-yearly

Repository files navigation

FacetWP -Yearly

Custom yearly source index

Requirements

Installation

First activate FacetWP. Then activate FacetWP - Yearly to create your yearly facet.

Create a Facet, for example a Select Facet, and choose "Yearly archive" as Data source.

image

Tips

By default, years are sorted by chronological order. If you want to reverse this order, you can use this snippet :

add_filter( 'facetwp_facet_orderby', 'sort_yearly_desc', 10, 2 );

function sort_yearly_desc( $orderby, $facet ) {
	if ( 'YOUR_FACET_NAME' === $facet['name'] ) {
		$orderby = 'f.facet_display_value DESC';
	}
	return $orderby;
}