get_the_permalink()WP 3.9.0

Gets, rather than displays, the URL of the post that is currently being processed in the Loop. Template tag.

get_the_permalink() is a copy of the get_permalink() function.

1 time — 0.002494 sec (very slow) | 50000 times — 7.14 sec (fast) | PHP 7.1.11, WP 4.9.8

No Hooks.


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


get_the_permalink( $post, $leavename );
Post ID or post object, which link we want to retrieve.
Default: global $post
Do not replace the name of the post in the link, i.e. do not replace the tag %postname% with the name of the post.
Default: false



#1 Example of use

Get a link to the current post in the loop:

<a href="<?php echo get_the_permalink(); ?>">Reed more...</a>

#2 Get the link to a specific post

$url = get_the_permalink( 23 ); //

#3 Second parameter: $leavename

The result depends on the permalink structure. Suppose that we have such a structure: %post_id%/%postname%.html, then:

$url = get_the_permalink( 23 );
echo get_the_permalink( 1, true );

// display:



Since 3.9.0 Introduced.

get_the_permalink() code WP 6.5.3

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