palmtree / wp-pagination

Palmtree PHP 的 WordPress 分页组件

v1.0.1 2022-05-30 10:33 UTC

This package is auto-updated.

Last update: 2024-08-29 04:31:31 UTC


README

Palmtree PHP 的 WordPress 分页组件

为主要的 WP_Query 或任何提供的查询生成分页,并使用 Bootstrap v4 类输出。

要求

  • PHP >= 7.1

安装

使用 composer 将包添加到依赖项

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');

许可证

MIT 许可证下发布