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

---

# comment_link( int|WP_Comment $comment = null )

## In this article

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

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

Displays the link to the comments.

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

 `$comment`int|[WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/)
optional

Comment object or ID. Defaults to global comment object.

Default:`null`

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

    ```php
    function comment_link( $comment = null ) {
    	/**
    	 * Filters the current comment's permalink.
    	 *
    	 * @since 3.6.0
    	 *
    	 * @see get_comment_link()
    	 *
    	 * @param string $comment_permalink The current comment permalink.
    	 */
    	echo esc_url( apply_filters( 'comment_link', get_comment_link( $comment ) ) );
    }
    ```

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

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

 [apply_filters( ‘comment_link’, string $comment_permalink )](https://developer.wordpress.org/reference/hooks/comment_link/)

Filters the current comment’s permalink.

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

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

Retrieves the link to a given comment.

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

Checks and cleans a URL.

  | 
| [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/comment_link/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/comment_link/?output_format=md#)

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

| Version | Description | 
| [4.4.0](https://developer.wordpress.org/reference/since/4.4.0/) | Introduced the `$comment` argument. | 
| [1.5.0](https://developer.wordpress.org/reference/since/1.5.0/) | Introduced. |

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

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/comment_link/?output_format=md#comment-content-1520)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/comment_link/#comment-1520)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_link%2F%23comment-1520)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_link%2F%23comment-1520)
 4. **Create an anchored permalink to a single comment.**
 5.     ```php
        <a href="<?php comment_link(); ?>">Permalink to this comment</a>
        ```
    
 6. The code shown above will result (depending on your permalink settings) in something
    like this:
 7.     ```php
        <a href="http://example.com/2009/07/15/example-post/comment-page-1/#comment-3">Permalink to this comment</a>
        ```
    
 8.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_link%2F%3Freplytocom%3D1520%23feedback-editor-1520)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fcomment_link%2F)
before being able to contribute a note or feedback.