Develop pagination function in WordPress

Tuesday, November 24th, 2015 (0 Comment)

Develop pagination function in wordpress. At frist, you need to capture image below to clearly about idea for this paging.

pagination function

pagination function

Description these define of pagination function:

$paged: variable of WordPress, it is current page but you need declare global $paged to use this variable.

$pages = $wp_query->max_num_pages; : return total number of pages, this function of WordPress.

$range: number of pages need to show before and after current page ($paged)

$showitems = ($rang * 2) + 1 : show number of pages and current page

For (i) loop from one to all page and only drawing in showitems. If variable <i> equal current page ($paged), set css highlight

<< First = 1 : return a first page

< Previous = $paged – 1 : return previous page (current page – 1)

Next > = $paged + 1 : return next page (current page + 1)

Last >> = $pages : return last page

Source code as below:

function pagination:

Css pagination.css for pagination function:

After clearly this pagination function, you can customize this function to display or format paging follow for purpose. You need to add this pagination function into file wordpress’s functions.php, and then call this pagination in single.php under function the_content() and must to put this function in while loop data. You can add pagination in many place if you want. for example: you want display paging when search, you add it in search.php file. The same, show in category –> add in category.php

Tags: , , ,

Related Posts

wordpress
Why should use WordPress Framework
wordpress
Create responsive menu in wordpress using bootstrap
wordpress
Create breadcrumbs function without plugin
wordpress
Related Posts functions in WordPress without using the plugin

Related Posts

wordpress
Why should use WordPress Framework
wordpress
Create responsive menu in wordpress using bootstrap
wordpress
Create breadcrumbs function without plugin
wordpress
Related Posts functions in WordPress without using the plugin

Leave a Reply

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