Displays the permalink for the current post.
Parameters
$post
int|WP_Postoptional- Post ID or post object. Default is the global
$post
.
Source
function the_permalink( $post = 0 ) {
/**
* Filters the display of the permalink for the current post.
*
* @since 1.5.0
* @since 4.4.0 Added the `$post` parameter.
*
* @param string $permalink The permalink for the current post.
* @param int|WP_Post $post Post ID, WP_Post object, or 0. Default 0.
*/
echo esc_url( apply_filters( 'the_permalink', get_permalink( $post ), $post ) );
}
Hooks
- apply_filters( ‘the_permalink’,
string $permalink ,int|WP_Post $post ) Filters the display of the permalink for the current post.
Used as Link With Title Tag
Creates a link for the permalink, with the post’s title as the link text. This is a common way to put the post’s title.
As Link With Text
You can use whatever text you like as the link text, in this case, “permalink”.
Display Post URL as Text
Displays the URL to the post, without creating a link: