get_the_permalink() WordPress Function

The get_the_permalink() function in WordPress allows you to easily retrieve the URL for a given post or page. This can be useful when you need to create links to specific content on your site.

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

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


Description

This function is an alias for get_permalink().

Top ↑

See also


Top ↑

Parameters

$post

(int|WP_Post)(Optional) Post ID or post object. Default is the global $post.

$leavename

(bool)(Optional) Whether to keep post name or page name.

Default value: false


Top ↑

Return

(string|false) The permalink URL or false if post does not exist.


Top ↑

Source

File: wp-includes/link-template.php

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


Top ↑

Changelog

Changelog
VersionDescription
3.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More