WordPress pagination component for Palmtree PHP
Generates pagination for the main WP_Query or any query provided and outputs with Bootstrap v4 classes.
- PHP >= 7.1
Use composer to add the package to your dependencies:
composer require palmtree/wp-pagination
<?php
$pagination = new \Palmtree\WordPress\Pagination\Pagination();
// Get Bootstrap formatted pagination
echo $pagination->getHtml();
// __toString() is also implemented, which implicitly calls getHtml()
echo $pagination;
// Or get an array of unstyled links
$links = $pagination->getLinks();
<?php
use Palmtree\WordPress\Pagination\Pagination;
$query = new \WP_Query();
$pagination = new Pagination();
$pagination->setQuery($query);
$pagination
->addArg('prev_text', 'Previous')
->addArg('next_text', 'Next');
Released under the MIT license