facetwp_pager_html
Overview
This filter lets you modify how the old pager appears.
Parameters
- $output | string | The pager HTML
- $params | array | An associative array of pagination settings (see below)
$params = [
'page' => 1,
'per_page' => 10,
'total_rows' => 205,
'total_pages' => 21
];
Usage
This example will output all page numbers:
add_filter( 'facetwp_pager_html', function( $output, $params ) {
$output = '';
if ( 1 < $params['total_pages'] ) {
for ( $i = 1; $i <= $params['total_pages']; $i++ ) {
$is_curr = ( $i === $params['page'] ) ? ' active' : '';
$output .= '<a class="facetwp-page' . $is_curr . '" data-page="' . $i . '">' . $i . '</a>';
}
}
return $output;
}, 10, 2 );
This example will output “Prev” and “Next” links:
add_filter( 'facetwp_pager_html', function( $output, $params ) {
$output = '';
$page = $params['page'];
$total_pages = $params['total_pages'];
if ( $page > 1 ) {
$output .= '<a class="facetwp-page" data-page="' . ($page - 1) . '">Previous</a>';
}
if ( $page < $total_pages && $total_pages > 1 ) {
$output .= '<a class="facetwp-page" data-page="' . ($page + 1) . '">Next</a>';
}
return $output;
}, 10, 2 );