Module Pager

描述

Module Pager displays pagination that can be adapted to your site’s design.

The Pagination Settings screen lets you edit separate HTML templates for the complete pager, previous link, next link, and page numbers.

Features

  • Edit pagination HTML from the WordPress admin screen.
  • Start with default templates that work immediately after activation.
  • Configure the previous and next links separately.
  • Use Mustache syntax to render page numbers and conditional states.
  • Restrict the HTML elements and attributes that can be saved.
  • Render pagination with a shortcode or from a theme’s PHP template.

Shortcode

Add the shortcode where the main query’s pagination should appear.

[wp-module-pager]

Use base_path to specify the base path for pagination URLs.

[wp-module-pager base_path="news"]

Use post_type when the post type needs to be specified explicitly.

[wp-module-pager post_type="news" base_path="news"]

PHP API

The following example renders pagination for the current main query from a theme template.

<?php
$pager = new Wp_Module_Pager();
$pager->render();

A custom WP_Query object, post type, and base path can also be passed to render().

<?php
$pager = new Wp_Module_Pager();
$pager->render( $custom_query, 'news', 'news' );

No pagination is rendered when the query has only one page.

安装

  1. Open Plugins > Add New Plugin in the WordPress admin screen.
  2. Search for “Module Pager” and install it.
  3. Activate the plugin.
  4. Review the default templates under Pagination Settings.
  5. Add the shortcode or PHP call where pagination should appear.

To install a ZIP file, use Upload Plugin on the Add Plugins screen.

常见问题

Why is the pagination not displayed?

Confirm that the target query contains enough posts to produce multiple pages.

The plugin does not output pagination for a single-page query.

Can the templates be restored to their defaults?

Select “Reset to defaults” on the Pagination Settings screen, and then save the settings.

Can I use a custom WP_Query?

Pass the WP_Query object as the first argument of the PHP API’s render() method.

The shortcode uses the WordPress main query.

评价

此插件暂无评价。

贡献者及开发者

「Module Pager」是开源软件。 以下人员对此插件做出了贡献。

贡献者

帮助将「Module Pager」翻译成简体中文。

对开发感兴趣吗?

您可以浏览代码,查看SVN仓库,或通过RSS订阅开发日志。

更新日志

1.7.0

  • Updated Mustache to version 3.
  • Added test environments for WordPress 7.0 and PHP 8.5.
  • Added automated tests for PHP 7.4 and PHP 8.5.
  • Fixed the shortcode to return its rendered HTML correctly.
  • Improved handling when the query string is unavailable or posts per page is zero.
  • Fixed line break preservation and default restoration on the Pagination Settings screen.
  • Registered default templates during plugin activation and added safe fallbacks for missing settings.
  • Improved JavaScript escaping for templates displayed in the admin screen.
  • Improved input validation and output escaping for Plugin Check compatibility.