How to display a comment reply link in WordPress

The comment_reply_link function in WordPress is used to generate a link that allows users to reply to a specific comment on a post or page. This link is typically displayed alongside the comment, making it easy for users to engage in threaded discussions.

This function can be useful for creating a more interactive and engaging comment section on a website. By allowing users to easily reply to specific comments, it encourages conversation and fosters a sense of community among site visitors.

Parameters Accepted by the comment_reply_link Function

The comment_reply_link function accepts the following parameters:

  • $args (array, optional): Override default options.
  • $comment (intWP_Comment, optional): Comment being replied to. Default is the current comment.
  • $post (intWP_Post, optional): Post ID or WP_Post object the comment is going to be displayed on. Default is the current post.

The function does not return a value.


Example 1: Basic Usage

    'reply_text' => 'Reply to This Comment',
    'depth'      => 1,
    'max_depth'  => 5

This example shows how to display a basic reply link with custom text. The depth parameter ensures the link is shown at the correct nesting level, and max_depth adheres to the maximum depth specified in the discussion settings.

Example 2: Customizing the Reply Link

    'add_below'  => 'comment-content',
    'respond_id' => 'respond',
    'reply_text' => 'Respond to this',
    'login_text' => 'Log in to Reply',
    'depth'      => 2,
    'before'     => '<div class="custom-reply-link">',
    'after'      => '</div>'

In this example, the reply link is highly customized. It specifies where the reply form should be added, customizes the text displayed on the link and for users who need to log in, and wraps the link in custom HTML for styling purposes.


The comment_reply_link() function is a powerful tool for WordPress theme developers, enabling them to easily incorporate interactive comment features into their themes. By understanding and utilizing the parameters this function accepts, developers can create more engaging and dynamic discussions on WordPress sites, encouraging community and conversation among users.

Related WordPress Functions