adjacent_post_link

Displays the adjacent post link.

Description

adjacent_post_link( (string) $format, (string) $link, (constant) $in_same_term = false, (string) $excluded_terms = '', (constant) $previous = true, (string) $taxonomy = 'category' ); 

Can be either next post link or previous.

Parameters (6)

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

Usage

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

Defined (1)

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

/wp-includes/link-template.php  
  1. function adjacent_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { 
  2. echo get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, $previous, $taxonomy );