WordPress Pagination without plugin

The default WordPress pagination only comes with the “Older posts” and “Newer posts” links at the bottom of the page when you want to navigate to the older entries. This works fine for sites with few entries, but isn’t very user-friendly for blogs and sites with dozens or even hundreds of pages worth of entries. To enable your visitors to quickly navigate your site and browse through your content from page to page, a list of numbered pages would be more useful, like Google’s search results.


Add the following function to your functions.php file:
Continue reading

Pagination in CakePHP

In the controller file like I have Employeecontroller.php, write the following code:

class EmployeeController extends AppController
public $paginate = array(
‘limit’ => 2,
‘order’ => array(
‘Employee.id’ => ‘asc’

public function index()
$data = $this->paginate(‘Employee’);
$this->set(’employeeList’, $data);

Now in the view file like I have index.ctp, write the following code:

<div align=”center”>
<!– Shows the page numbers –>
<?php echo $this->Paginator->numbers(); ?>
<!– Shows the next and previous links –>
<?php echo $this->Paginator->prev(‘« Previous ‘, null, null, array(‘class’ => ‘disabled’)); ?>
<?php echo $this->Paginator->next(‘ Next »’, null, null, array(‘class’ => ‘disabled’)); ?>
<!– prints X of Y, where X is current page and Y is number of pages –>
<?php echo $this->Paginator->counter(); ?>