Functions/get previous item

get_previous_item will return the previous item in archive, relative to a specific item.

Usage

<?php
get_previous_item($item);
?>

Arguments

  • $item - The item object for which you want to get the previous item. If null, the current item available will be used.

Examples

The following example, which can be used on the items/show.php template in any theme, will get the previous item, and display the title, description, and link for it. We'll pass the `$previousItem` object we create to the link_to_item and item helpers, to display its metadata.

<?php
 
$previousItem = get_previous_item(); // No argument b/c we want the current item.
if($previousItem):
?>
<h2><?php echo link_to_item(null, array(), 'show', $previousItem); ?></h2>
<p><?php echo item('Dublin Core', 'Description', array(), $previousItem); ?></p>
<?php endif; ?>