<?php
/** shows prev link while on page 1 and next link while on last page
**/
add_filter( 'facetwp_facet_html', function( $output, $params ) {
if ( 'standard_pager' == $params['facet']['name'] ) { // change 'standard_pager' to name of your pager facet
$page = FWP()->facet->pager_args['page'];
$total = FWP()->facet->pager_args['total_pages'];
if ( 2 > $page ) { // if this is page 1
// add the prev page link
$label = facetwp_i18n( $params['facet']['prev_label'] );
$class = 'facetwp-page prev active';
$data = ' data-page="1"';
$html = '<a class="' . $class . '"' . $data . '>' . $label . '</a>';
$output = str_replace( '<div class="facetwp-pager">', '<div class="facetwp-pager">' . $html, $output );
} elseif ( $page == $total) { // if this is last page
// add the next page link
$label = facetwp_i18n( $params['facet']['next_label'] );
$class = 'facetwp-page next active';
$data = ' data-page="' . $page .'"';
$html = '<a class="' . $class . '"' . $data . '>' . $label . '</a>';
$output = str_replace( '</div>', $html . '</div>', $output ); //
}
}
return $output;
}, 10, 2 );