The get_comment_reply_link() WordPress PHP function retrieves the HTML content for a reply-to-comment link.
Usage
get_comment_reply_link($args, $comment, $post)
Custom example:
$args = array(
'reply_text' => 'Respond to this comment',
'before' => '<div class="reply-link">',
'after' => '</div>'
);
echo get_comment_reply_link($args);
Parameters
$argsarray (Optional): Override default arguments.add_belowstring: The first part of the selector used to identify the comment to respond below. Default ‘comment’.respond_idstring: The selector identifying the responding comment. Default ‘respond’.reply_textstring: The text of the Reply link. Default ‘Reply’.login_textstring: The text of the link to reply if logged out. Default ‘Log in to Reply’.max_depthint: The max depth of the comment tree. Default 0.depthint: The depth of the new comment. Default 0.beforestring: The text or HTML to add before the reply link.afterstring: The text or HTML to add after the reply link. Default: array()
$commentint|WP_Comment (Optional): Comment being replied to. Default current comment. Default: null$postint|WP_Post (Optional): Post ID or WP_Post object the comment is going to be displayed on. Default current post. Default: null
More information
See WordPress Developer Resources: get_comment_reply_link()
Examples
Customize Reply Text
Change the reply link text to “Respond to this comment.”
$args = array(
'reply_text' => 'Respond to this comment'
);
echo get_comment_reply_link($args);
Add Custom Wrapper
Add a custom wrapper around the reply link.
$args = array(
'before' => '<div class="custom-reply-link">',
'after' => '</div>'
);
echo get_comment_reply_link($args);
Customize Login Text
Change the login text for users who are not logged in.
$args = array(
'login_text' => 'Sign in to leave a comment'
);
echo get_comment_reply_link($args);
Set Max Depth and Depth
Set the max depth and depth of comment tree.
$args = array(
'max_depth' => 3,
'depth' => 1
);
echo get_comment_reply_link($args);
Add Custom ID for Responding Comment
Set a custom ID for the responding comment.
$args = array(
'respond_id' => 'custom-respond-id'
);
echo get_comment_reply_link($args);