previous_post_link

Displays the previous post link that is adjacent to the current post.

Description

previous_post_link( , , (constant) $in_same_term = false, (string) $excluded_terms = '', (string) $taxonomy = 'category' ); 

Parameters (5)

0. $format — Optional. (string) => '« %link'
Link anchor format. Default « %link..
1. $link — Optional. (string) => '%title'
Link permalink format. Default %title..
2. $in_same_term — Optional. (constant) => false
Whether link should be in a same taxonomy term. Default false.
3. $excluded_terms — Optional. (string) => ''
Array or comma-separated list of excluded term IDs. Default empty.
4. $taxonomy — Optional. (string) => 'category'
Taxonomy, if $in_same_term is true. Default category..

Usage

  1. if ( !function_exists( 'previous_post_link' ) ) { 
  2. require_once ABSPATH . WPINC . '/link-template.php'; 
  3.  
  4. // Optional. Link anchor format. Default '« %link'. 
  5. $format = '« %link'; 
  6.  
  7. // Optional. Link permalink format. Default '%title'. 
  8. $link = '%title'; 
  9.  
  10. // Optional. Whether link should be in a same taxonomy term. Default false. 
  11. $in_same_term = false; 
  12.  
  13. // Optional. Array or comma-separated list of excluded term IDs. Default empty. 
  14. $excluded_terms = ''; 
  15.  
  16. // Optional. Taxonomy, if $in_same_term is true. Default 'category'. 
  17. $taxonomy = 'category'; 
  18.  
  19. // NOTICE! Understand what this does before running. 
  20. $result = previous_post_link($format, $link, $in_same_term, $excluded_terms, $taxonomy); 
  21.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/link-template.php  
  1. function previous_post_link( $format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) { 
  2. echo get_previous_post_link( $format, $link, $in_same_term, $excluded_terms, $taxonomy );