get_the_permalink( int|WP_Post $post, bool $leavename = false ): string|false

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

Description

This function is an alias for get_permalink() .

See also

Parameters

$postint|WP_Postoptional
Post ID or post object. Default is the global $post.
$leavenamebooloptional
Whether to keep post name or page name.

Default:false

Return

string|false The permalink URL. False if the post does not exist.

Source

function get_the_permalink( $post = 0, $leavename = false ) {
	return get_permalink( $post, $leavename );
}

Changelog

VersionDescription
3.9.0Introduced.

User Contributed Notes

  1. Skip to note 2 content
    get_the_permalink( $post_id, false );
    // Returns URL with post's slug, e.g.: "https://example.com/2025/01/my-post-title/"
    
    get_the_permalink( $post_id, true );
    // Returns URL with generic post placeholder: "https://example.com/2025/01/%postname%/"

You must log in before being able to contribute a note or feedback.