get_boundary_post() – Function description, parameters and basic usage

Description:

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.

Parameters:

$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:

<?php
$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; ?>
About Pavel Petrov 2 Articles |  21 How-tos
Pavel is a senior developer for the last 7 years, with extended interest in Linux administration, WordPress and Symfony.

Be the first to comment

Leave a Reply

Your email address will not be published.


*