I want to retrieve the comment url of last 5 comments.

Is it Possible and how?

when using get_permalink($comment->comment_post_ID) it returns current page url


If you mean, the last 5 comments on anything:

$comments = get_comments( array( 'count' => 5 ) );
foreach( $comments as $comment ) {
    echo get_comment_link( $comment );

For a specific post or page comments, just change the $comments line to:

$comments = get_comments( array( 'post_id' => 1, 'count' => 5 ) ); // where the value of post_id is the ID of whatever post or page you want to retrieve comments from

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.