A custom WordPress numbered pagination function to fully implement the Bootstrap 3.x pagination/pager style in a custom theme.
- Autor URI: OOPThemes
- Forum: OOPThemes Discussio
- Bootstrap Styling
- First & Last Buttoon
- Next & Previous Button
- Glyphicon can be added instead of Next & Pervious values
- Filter to overwrite values
Below is the example of the Bootstrap WordPress Pagination. You can customize it with your own CSS styling.
Place wp_bootstrap_pagination.php in your WordPress theme folder /wp-content/your-theme/
Open your WordPress themes functions.php file /wp-content/your-theme/functions.php
and add the following code:
// Register Custom Navigation Walker
require_once('wp_bootstrap_pagination.php');
or simply open the wp_bootstrap_pagination.php copy all the code and paste it in your themes functions.php file
Update your index.php or template-blog.php or any other file where you want to show the pagination. Add the below code into the file to show the Bootstrap WordPress Pagination.
<?php
if ( function_exists('wp_bootstrap_pagination') )
wp_bootstrap_pagination();
?>
if pagination is not showing, go to WordPress Dashboard > Reading > Blog pages show at most > set value smaller then number of posts your blog has.
To filter next and previous values use the following snippet into functions.php
function customize_wp_bootstrap_pagination($args) {
$args['previous_string'] = 'previous';
$args['next_string'] = 'next';
return $args;
}
add_filter('wp_bootstrap_pagination_defaults', 'customize_wp_bootstrap_pagination');