the_permalink()WP 1.2.0

Displays link (URL) to the post that is currently being processed in the Loop.

This template tag can be used only inside the Loop of WordPress.

1 time — 0.002275 sec (very slow) | 50000 times — 5.62 sec (fast) | PHP 7.1.2, WP 4.7.3
Hooks from the function

Return

null. Nothing (null).

Usage

the_permalink( $post );
$post(int|WP_Post)
Post ID or post object.
Default: global $post

Examples

0

#1 Let's display a link to the post in the form of simple text, not html link

Address of this post: <?php the_permalink(); ?>
0

#2 Let's display html link to the current post

The link text will be: "permanent link":

<a href="<?php the_permalink(); ?>">permanent link</a>
0

#3 Display a link to the current post

The text of the link will be the title of the post.

This is the standard way to output a link to a post within a Loop:

<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>

Changelog

Since 1.2.0 Introduced.
Since 4.4.0 Added the $post parameter.

the_permalink() code WP 6.7.1

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 ) );
}