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)
How to use custom PHP code?
PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info
$params = [ 'page' => 1, 'per_page' => 10, 'total_rows' => 205, 'total_pages' => 21 ];
Usage
This example will output all page numbers:
How to use custom PHP code?
PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info
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:
How to use custom PHP code?
PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info
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 );