CodeIn House

  • Laravel
  • WordPress
  • jQuery
  • Javascript
  • Contact
Home   WordPress   WordPress Numbered Pagination Using Bootstrap & CSS

WordPress Numbered Pagination Using Bootstrap & CSS

July 8, 2018 by SNK

Today we are going to change the WordPress pagination to WordPress numbered pagination. That means we are going to have number based pagination in WordPress. It works for all custom post types as well as all the blog post as well.

We will  just create a simple function that will override the inbuilt WordPress pagination functionality and use the number based pagination that we will create. We will take step by step process and learn how to create number based pagination in WordPress using bootstrap and little but of custom css.

Lets get started.

What we are going to do ?

  1. Create a function inside functions.php
  2. Call the function on the theme index template.

How to Create WordPress Numbered Pagination Using Bootstrap ?

Firstly we will create a hook that will override current pagination function in WordPress.

Lets create one

functions.php
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function cih_numeric_pagination() {
 
gloal $wp_query;
 
$posts_limit = 999999999 // Most be inside integer rage
 
$pages = paginate_links(array(
 
'base'=>str_replace($posts_limit, '%#%', esc_url(get_page_num($big))),
'format'=>'?paged=%#%',
'current'=> max(1,get_query_var('paged')),
'total' => $wp_query->max_num_pages,
'type' => 'array',
'prev_text' => '<i class="fa fa-angle-left"></i>',
'next_text' => '<i class="fa fa-angle-right"></i>',
));
 
if(is_array( $pages )) {
 
$paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');
echo '<div class="pagination-wrap"><ul class="pagination">';
foreach($pages as $page) {
echo "<li>$page</li>";
}
echo "</ul></div>";
}
}

After you have copied the code inside your functions.php, its time to call it in your index page or archive page or wherever you want. Make sure page is using bootstrap framework to see the changes.

In my case it would be inside index.php for similar type of files.

If you run into any problem, feel free to leave the comment.

SHARE ON
Buffer

Enjoyed this article?

Like us on

WordPress wordpress numbered pagination wordpress pagination wordpress pagination css

Avatar for SNK

About SNK

Hello Welcome to my Blog. I develop Websites Using Laravel Framwork & WordPress. Get Latest updates on Facebook | Twitter

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Get Connected !! With Us

TOP POSTS

  • How to Setup Spring MVC Project From Scratch in Intellij IDEA ?
  • Spring Configuration Class in JAVA [Class VS XML Config]
  • Annotations Based Configuration in Spring Framework
  • How to Configure Spring Framework with XML Configurations?
  • How to Remove Project Name from URL in JSP Project in Intellij IDEA ?

TUTORIALS TILL DATE

  • September 2022 (6)
  • June 2021 (7)
  • October 2020 (5)
  • September 2020 (6)
  • September 2018 (14)
  • August 2018 (3)
  • July 2018 (4)
  • March 2018 (8)
  • February 2018 (5)
  • January 2018 (1)
  • December 2017 (2)
  • August 2017 (8)
  • May 2017 (1)
  • April 2017 (1)
  • March 2017 (4)
  • February 2017 (3)
  • January 2017 (4)

CATEGORIES

  • Angular (2)
  • CSS3 (3)
  • D3 (3)
  • HTML5 (7)
  • JAVA (11)
  • Javascript (20)
  • jQuery (8)
  • Laravel (35)
  • Others (3)
  • PHP (11)
  • Spring (2)
  • WordPress (10)

Top Categories

  • Angular
  • CSS3
  • D3
  • HTML5
  • JAVA
  • Javascript
  • jQuery
  • Laravel
  • Others
  • PHP
  • Spring
  • WordPress

Get in Touch

DMCA.com Protection Status

Recent Articles

  • How to Setup Spring MVC Project From Scratch in Intellij IDEA ?
  • Spring Configuration Class in JAVA [Class VS XML Config]
  • Annotations Based Configuration in Spring Framework
  • How to Configure Spring Framework with XML Configurations?
  • How to Remove Project Name from URL in JSP Project in Intellij IDEA ?

© 2012-22 CodeIn House.  •  All Rights Reserved.