next_post()

Description

Outputs a link to the next post. Can also return an array with details about the next post so that you can display the post's title, for example.

Note that this function loops, which means that when the last post is reached, the link returned will point to the first post.

Example array:

Array
(
    [id]        => 2
    [slug]      => example-post
    [date]      => 1302384138
    [title]     => Example Post
    [post]      => This is a totally riveting post.
    [image]     => lolcats.gif
    [status]    => 1
    [link]      => http://secretarycms.com/beta/site/site.php?page=blog&id=example-post
)

Usage

<?php
    echo next_post();
    $next_post= next_post( $return_data );
?>

Parameters

$return_data

  • true or false
  • optional
  • default: false

True will force the function to return an array containing details about the next post.

Examples

Creating a standard next post link

<a href="<?php echo next_post(); ?>">Next post</a>

Using post details array in a link

<?php $next_post= next_post( true ); ?>
<a href="<?php echo $next_post['link']; ?>"><?php echo $next_post['title']; ?></a>