Page Navigational Functions:

Posted on April 18th, 2011

posts_nav_link() :-For index category, and archive pages


Default usage:

<?php posts_nav_link(); ?>

Parameters

<?php posts_nav_link(‘sep’,'prelabel’,'nxtlabel’); ?>

  • sep — text/markup that is displayed between the links
  • prelabel — text/markup that is used as the link text for the previous page
  • nxtlabel — text/markup that is used as the link text for the next page

previous_posts_link() and next_posts_link():- For index category, and archive pages


Default usage:

<?php previous_posts_link(); ?> &bull; <?php next_posts_link(); ?>

Parameters

<?php previous_posts_link('label','max_pages'); ?>
<?php next_posts_link('label','max_pages'); ?>

previous_post_link() and next_post_link():-separate links for single-view post navigation


Default usage

<?php previous_post_link(); ?> &bull; <?php next_post_link(); ?>

Parameters

<?php next_post_link(‘format’,'link’,'in_same_cat’,'excluded_categories’); ?>
<?php previous_post_link(‘format’,'link’,'in_same_cat’,'excluded_categories’); ?>

  • format — format string for the link. Here you specify the text/HTML to appear before and after the link. The link itself is specified according to the link parameter by including the %link variable in the format string. For example, a format value of “Next: %link &raquo;” will result in the following output: “Next The Post Title »”
  • link — link text to display. Anything specified here will be used as the %link variable in the format parameter (see previous). By default, this parameter returns the post title via the %title variable. For example, a link parameter with a value of “[[%title]]” will result in the following output: “[[The Post Title]] »”
  • in_same_cat — boolean value indicating whether or not the next or previous post must be in the same category as the current post. If set to TRUE, only posts from the current category will be displayed. Options are: TRUE or FALSE (default).
  • excluded_categories — string indicating any collection of category IDs from which the next post should not be listed. In all versions of WordPress except 2.2, multiple categories are separated via “ and ”, for example: ‘1 and 3 and 7’ Oddly enough, in WordPress version 2.2, a comma is used to concatenate multiple excluded categories, for example: ‘1, 3, 7’