get_the_permalink

Retrieves the full permalink for the current post or post ID.

Description

(string|false) get_the_permalink( (int) $post = 0, (bool) $leavename = false ); 

This function is an alias for get_permalink().

Returns (string|false)

The permalink URL or false if post does not exist.

Parameters (2)

0. $post — Optional. (int)
Post ID or post object. Default is the global $post..
1. $leavename — Optional. (bool) => false
Whether to keep post name or page name. Default false.

Usage

  1. if ( !function_exists( 'get_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. // Optional. Whether to keep post name or page name. Default false. 
  8. $leavename = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = get_the_permalink($post, $leavename); 
  12.  

Defined (1)

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

/wp-includes/link-template.php  
  1. function get_the_permalink( $post = 0, $leavename = false ) { 
  2. return get_permalink( $post, $leavename );