next_post

Prints link to the next post.

Description

next_post( , (string) $next = 'next post: ', (string) $title = 'yes', (string) $in_same_cat = 'no', (int) $limitnext = 1, (string) $excluded_categories = '' ); 

Parameters (6)

0. $format — Optional. (string) => '%'
The format.
1. $next — Optional. (string) => 'next post: '
The next.
2. $title — Optional. (string) => 'yes'
The title.
3. $in_same_cat — Optional. (string) => 'no'
The in same cat.
4. $limitnext — Optional. (int) => 1
The limitnext.
5. $excluded_categories — Optional. (string) => ''
The excluded categories.

Usage

  1. if ( !function_exists( 'next_post' ) ) { 
  2. require_once ABSPATH . WPINC . '/deprecated.php'; 
  3.  
  4. // The format. 
  5. $format = '%'; 
  6.  
  7. // The next. 
  8. $next = 'next post: '; 
  9.  
  10. // The title. 
  11. $title = 'yes'; 
  12.  
  13. // The in same cat. 
  14. $in_same_cat = 'no'; 
  15.  
  16. // The limitnext. 
  17. $limitnext = 1; 
  18.  
  19. // The excluded categories. 
  20. $excluded_categories = ''; 
  21.  
  22. // NOTICE! Understand what this does before running. 
  23. $result = next_post($format, $next, $title, $in_same_cat, $limitnext, $excluded_categories); 
  24.  

Defined (1)

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

/wp-includes/deprecated.php  
  1. function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') { 
  2. _deprecated_function( __FUNCTION__, '2.0.0', 'next_post_link()' ); 
  3.  
  4. if ( empty($in_same_cat) || 'no' == $in_same_cat ) 
  5. $in_same_cat = false; 
  6. else 
  7. $in_same_cat = true; 
  8.  
  9. $post = get_next_post($in_same_cat, $excluded_categories); 
  10.  
  11. if ( !$post ) 
  12. return; 
  13.  
  14. $string = '<a href="'.get_permalink($post->ID).'">'.$next; 
  15. if ( 'yes' == $title ) 
  16. $string .= apply_filters('the_title', $post->post_title, $post->ID); 
  17. $string .= '</a>'; 
  18. $format = str_replace('%', $string, $format); 
  19. echo $format;