next_posts_link()显示同分类“下一页”分页的链接

目录

描述

Prints a link to the next set of posts within the current query.

If you need the values for use in PHP, use get_next_posts_link().

Because post queries are usually sorted in reverse chronological order, next_posts_link() usually points to older entries (toward the end of the set) and previous_posts_link() usually points to newer entries (toward the beginning of the set).

next_posts_link() 描述

用法

 <?php next_posts_link$label $max_pages ); ?> 

next_posts_link() 用法

参数

$label

(string) (可选) The link text.

默认值: 'Next Page »'

$max_pages

(integer) (可选) Limit the number of pages on which the link is displayed. The default value "0" means "no limit".

默认值: 0

next_posts_link() 参数

示例

Default Usage

Working example

Usage when querying the loop with WP_Query

Add the $max_pages parameter to the next_posts_link() function when querying the loop with WP_Query. To get the total amount of pages you can use the 'max_num_pages' property of the custom WP_Query object.

next_posts_link() 示例

注意

  • This function will not work (fail silently) if mysql.trace_mode is enabled in your php.ini. If you can't edit that file, try adding ini_set( 'mysql.trace_mode', 0 ); to your theme's functions.php.

next_posts_link() 注意

历史

添加于 版本: 0.71

next_posts_link() 历史

源文件

next_posts_link() 函数的代码位于 wp-includes/link-template.php.

next_posts_link() 源文件

相关