the_permalink( int|WP_Post $post )

Displays the permalink for the current post.


Description Description


Parameters Parameters

$post

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


Top ↑

Source Source

File: wp-includes/link-template.php

17
18
19
20
21
22
23
24
25
26
27
28
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 ) );
}

Top ↑

Changelog Changelog

Changelog
Version Description
4.4.0 Added the $post parameter.
1.2.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 2 content
    Contributed by Codex

    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.

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

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