get_next_posts_link()调用同分类“下一页”分页的链接

目录

描述

Gets a link to the previous set of posts within the current query.

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

Note: See Troubleshooting Broken Pagination if you have pagination issues.

get_next_posts_link() 描述

用法

 <?php echo get_next_posts_link$label$max_page ); ?> 

get_next_posts_link() 用法

参数

$label

(string) (可选) The content for the link text

默认值: Next Page »

$max_page

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

默认值: 0

get_next_posts_link() 参数

返回值

Link to next page if successful, otherwise null.

get_next_posts_link() 返回值

示例

Default Usage

Custom Label

Custom Label and Custom number of post pages

Usage when querying the loop with WP_Query

Add the $max_pages parameter to the get_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.

get_next_posts_link() 示例

历史

添加于 版本 2.7.0

get_next_posts_link() 历史

源文件

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

get_next_posts_link() 源文件