Title: the_permalink
Published: April 25, 2014
Last modified: August 20, 2026

---

# the_permalink( int|WP_Post $post )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#parameters)
 * [More Information](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#wp--skip-link--target)

Displays the permalink for the current post.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#parameters)󠁿

 `$post`int|[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)
optional

Post ID or post object. Default is the global `$post`.

## 󠀁[More Information](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#more-information)󠁿

This tag must be within [The Loop](https://codex.wordpress.org/The_Loop), and is
generally used to display the permalink for each post, when the posts are being 
displayed. Since this template tag is limited to displaying the permalink for the
post that is being processed, you cannot use it to display the permalink to an arbitrary
post on your weblog. Refer to [get_permalink()](https://developer.wordpress.org/reference/functions/get_permalink/)
if you want to get the permalink for a post, given its unique post id.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#source)󠁿

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

[View all references](https://developer.wordpress.org/reference/files/wp-includes/link-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/link-template.php#L17)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/link-template.php#L17-L28)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#hooks)󠁿

 [apply_filters( ‘the_permalink’, string $permalink, int|WP_Post $post )](https://developer.wordpress.org/reference/hooks/the_permalink/)

Filters the display of the permalink for the current post.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#related)󠁿

| Uses | Description | 
| [esc_url()](https://developer.wordpress.org/reference/functions/esc_url/)`wp-includes/formatting.php` |

Checks and cleans a URL.

  | 
| [get_permalink()](https://developer.wordpress.org/reference/functions/get_permalink/)`wp-includes/link-template.php` |

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

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#)

| Used by | Description | 
| [print_embed_sharing_dialog()](https://developer.wordpress.org/reference/functions/print_embed_sharing_dialog/)`wp-includes/embed.php` |

Prints the necessary markup for the embed sharing dialog.

  | 
| [permalink_link()](https://developer.wordpress.org/reference/functions/permalink_link/)`wp-includes/deprecated.php` |

Print the permalink of the current post in the loop.

  | 
| [WP_Widget_Recent_Posts::widget()](https://developer.wordpress.org/reference/classes/wp_widget_recent_posts/widget/)`wp-includes/widgets/class-wp-widget-recent-posts.php` |

Outputs the content for the current Recent Posts widget instance.

  | 
| [trackback_rdf()](https://developer.wordpress.org/reference/functions/trackback_rdf/)`wp-includes/comment-template.php` |

Generates and displays the RDF for the trackback information of current post.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.4.0](https://developer.wordpress.org/reference/since/4.4.0/) | Added the `$post` parameter. | 
| [1.2.0](https://developer.wordpress.org/reference/since/1.2.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 4 content](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#comment-content-451)
 2.    [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/the_permalink/#comment-451)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_permalink%2F%23comment-451)
     Vote results for this note: 7[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_permalink%2F%23comment-451)
 4.  **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.
 5.      ```php
         <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
         ```
     
 6.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_permalink%2F%3Freplytocom%3D451%23feedback-editor-451)
 7.   [Skip to note 5 content](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#comment-content-450)
 8.    [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/the_permalink/#comment-450)
 9.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_permalink%2F%23comment-450)
     Vote results for this note: 4[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_permalink%2F%23comment-450)
 10. **As Link With Text**
      You can use whatever text you like as the link text, in
     this case, “permalink”.
 11.     ```php
         <a href="<?php the_permalink(); ?>">permalink</a>
         ```
     
 12.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_permalink%2F%3Freplytocom%3D450%23feedback-editor-450)
 13.  [Skip to note 6 content](https://developer.wordpress.org/reference/functions/the_permalink/?output_format=md#comment-content-449)
 14.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/the_permalink/#comment-449)
 15. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_permalink%2F%23comment-449)
     Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_permalink%2F%23comment-449)
 16. **Display Post URL as Text**
      Displays the URL to the post, without creating a
     link:
 17.     ```php
         This address for this post is: <?php the_permalink(); ?>
         ```
     
 18.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_permalink%2F%3Freplytocom%3D449%23feedback-editor-449)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fround-lake.dustinice.workers.dev%3A443%2Fhttps%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fthe_permalink%2F)
before being able to contribute a note or feedback.