_wp_link_page

Helper function for wp_link_pages().

Description

(string) _wp_link_page( (int) $i ); 

Returns (string)

Link.

Parameters (1)

0. $i (int)
Page number.

Usage

  1. if ( !function_exists( '_wp_link_page' ) ) { 
  2. require_once ABSPATH . WPINC . '/post-template.php'; 
  3.  
  4. // Page number. 
  5. $i = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = _wp_link_page($i); 
  9.  

Defined (1)

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

/wp-includes/post-template.php  
  1. function _wp_link_page( $i ) { 
  2. global $wp_rewrite; 
  3. $post = get_post(); 
  4. $query_args = array(); 
  5.  
  6. if ( 1 == $i ) { 
  7. $url = get_permalink(); 
  8. } else { 
  9. if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) 
  10. $url = add_query_arg( 'page', $i, get_permalink() ); 
  11. elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID ) 
  12. $url = trailingslashit(get_permalink()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged'); 
  13. else 
  14. $url = trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged'); 
  15.  
  16. if ( is_preview() ) { 
  17.  
  18. if ( ( 'draft' !== $post->post_status ) && isset( $_GET['preview_id'], $_GET['preview_nonce'] ) ) { 
  19. $query_args['preview_id'] = wp_unslash( $_GET['preview_id'] ); 
  20. $query_args['preview_nonce'] = wp_unslash( $_GET['preview_nonce'] ); 
  21.  
  22. $url = get_preview_post_link( $post, $query_args, $url ); 
  23.  
  24. return '<a href="' . esc_url( $url ) . '">';