the_permalink

Displays the permalink for the current post.

Description

the_permalink( (int) $post = 0 ); 

Parameters (1)

0. $post — Optional. (int)
Post ID or post object. Default is the global $post..

Usage

  1. if ( !function_exists( 'the_permalink' ) ) { 
  2. require_once ABSPATH . WPINC . '/link-template.php'; 
  3.  
  4. // Optional. Post ID or post object. Default is the global `$post`. 
  5. $post = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = the_permalink($post); 
  9.  

Defined (1)

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

/wp-includes/link-template.php  
  1. function the_permalink( $post = 0 ) { 
  2. /** 
  3. * Filters the display of the permalink for the current post. 
  4. * @since 1.5.0 
  5. * @since 4.4.0 Added the `$post` parameter. 
  6. * @param string $permalink The permalink for the current post. 
  7. * @param int|WP_Post $post Post ID, WP_Post object, or 0. Default 0. 
  8. */ 
  9. echo esc_url( apply_filters( 'the_permalink', get_permalink( $post ), $post ) );