Codex

Attention Help us to improve the Codex by filling out our documentation survey!

Function Reference/next posts link

Contents

Description

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).

Usage

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

Parameters

$label
(string) (optional) The link text.
Default: 'Next Page »'
$max_pages
(integer) (optional) Limit the number of pages on which the link is displayed. The default value "0" means "no limit".
Default: 0

Examples

Default Usage

<?php next_posts_link(); ?>

Working example

<?php next_posts_link('Older Entries »', 0); ?>

Notes

  • 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.

Resources

Change Log

Since: 0.71

Source File

next_posts_link() is located in wp-includes/link-template.php.

Related

Pagination: posts_nav_link(), next_posts_link(), previous_posts_link(), get_next_posts_link(), get_previous_posts_link(), paginate_links() wp_link_pages(), next_post_link(), previous_post_link(), next_image_link(), previous_image_link(),

See also index of Function Reference and index of Template Tags.