prev_post()

Description

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

Note that this function loops, which means that when the first post is reached, the link returned will point to the last 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 prev_post();
    $prev_post= prev_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 previous post.

Examples

Creating a standard next post link

<a href="<?php echo prev_post(); ?>">Previous post</a>

Using post details array in a link

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