get_boundary_post is very useful if you want to include show first or last post button below your single post or in you main index page.


$in_same_cat(optional)(boolean) – true if you want to show the first/last post for the current category $excluded_categories(optional)(string) – String of comma-separated category ids $start(optional)(boolean) – true to show first

Basic usage examples:

$firstPost = get_boundary_post(true, "", true));
$lastPost = get_boundary_post(true);

<?php if($firstPost) : ?>
<a href="<?php echo get_permalink($firstPost->ID)?>">&laquo; First post</a>
<?php endif; ?>

<?php if($lastPost) : ?>
<a href="<?php echo get_permalink($lastPost->ID)?>">Next: <?php echo $lastPost->post_title; ?> &raquo;</a>
<?php endif; ?>