Title: Comment link
Last modified: August 20, 2016

---

# Comment link

 *  [zolyman](https://wordpress.org/support/users/zolyman/)
 * (@zolyman)
 * [15 years ago](https://wordpress.org/support/topic/comment-link-4/)
 * I have the next code for the recent comments widget.
 * `<?php echo strip_tags($comment->comment_author); ?>: <a style="margin: 0 0 5px
   0;" href="<?php echo get_permalink($comment->ID); ?>#comment-<?php echo $comment-
   >comment_ID; ?>" title="on <?php echo $comment->post_title; ?>"><?php echo wp_html_excerpt(
   $comment->comment_content, 45 ); ?>... </a>`
 * Comment link does not lead me to comment right. Where is the problem?
    This is
   the blog: [http://blogaming.info](http://blogaming.info) (look in sidebar at “
   Comentarii recente” widget).
 * Ps: sorry for my english

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years ago](https://wordpress.org/support/topic/comment-link-4/#post-2103493)
 * instead of `get_permalink($comment->ID)`
    try [http://codex.wordpress.org/Function_Reference/get_comment_link](http://codex.wordpress.org/Function_Reference/get_comment_link)
 *  Thread Starter [zolyman](https://wordpress.org/support/users/zolyman/)
 * (@zolyman)
 * [15 years ago](https://wordpress.org/support/topic/comment-link-4/#post-2103494)
 * I tried already. It’s not working.
 *  Thread Starter [zolyman](https://wordpress.org/support/users/zolyman/)
 * (@zolyman)
 * [15 years ago](https://wordpress.org/support/topic/comment-link-4/#post-2103664)
 * I tried this:
 *     ```
       <?php 	$comments = get_comments('status=approve&number=5'); ?>
       <div class="recentcomm">
       <ul>
       	<?php foreach ($comments as $comment) { ?>
       		<li>
       			<div style="margin:0 10px 0 0;float:left;"><?php echo get_avatar( $comment, '35' ); ?></div>
       			<?php echo strip_tags($comment->comment_author); ?>: <a style="margin: 0 0 5px 0;" href="<?php echo get_permalink($comment->ID) . '#comment-' . $comment->comment_ID; ?>"><?php echo wp_html_excerpt( $comment->comment_content, 45 ); ?>... </a>
       		</li><div style="clear:both;margin:0 0 5px 0;"></div>
       	<?php }  ?>
       </ul>
       </div>
       ```
   
 * Still not working. Any ideas? Please, help me!
 *  [sdelamorena](https://wordpress.org/support/users/sdelamorena/)
 * (@sdelamorena)
 * [15 years ago](https://wordpress.org/support/topic/comment-link-4/#post-2103687)
 * Try with this (The same fragment of code):
 *     ```
       <?php $comments = get_comments('status=approve&number=5'); ?>
        <div class="recentcomm">
          <ul>
             <?php foreach ($comments as $comment) { ?>
       	<li>
       		<div style="margin:0 10px 0 0;float:left;"><?php echo get_avatar( $comment, '35' ); ?></div>
       		<?php echo strip_tags($comment->comment_author); ?>:
                       <a style="margin: 0 0 5px 0;" href="<?php echo get_permalink($comment->comment_post_ID).'#comment-'.$comment->comment_ID ?>"><?php echo wp_html_excerpt( $comment->comment_content, 45 ); ?>... </a>
       	</li>
               <div style="clear:both;margin:0 0 5px 0;"></div>
             <?php }  ?>
          </ul>
        </div>
       ```
   
 * Or replace the href content with the right comment link:
 * `<?php echo get_permalink($comment->comment_post_ID).'#comment-'.$comment->comment_ID?
   >`
 *  Thread Starter [zolyman](https://wordpress.org/support/users/zolyman/)
 * (@zolyman)
 * [15 years ago](https://wordpress.org/support/topic/comment-link-4/#post-2103721)
 * Thank you!
 * It works with `<?php echo get_permalink($comment->comment_post_ID).'#comment-'.
   $comment->comment_ID ?>` at href.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Comment link’ is closed to new replies.

## Tags

 * [get_permalink](https://wordpress.org/support/topic-tag/get_permalink/)

 * 5 replies
 * 3 participants
 * Last reply from: [zolyman](https://wordpress.org/support/users/zolyman/)
 * Last activity: [15 years ago](https://wordpress.org/support/topic/comment-link-4/#post-2103721)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
