Using WordPress ‘post_reply_link()’ PHP function

The post_reply_link() WordPress PHP function displays the HTML content for a reply to post link.


post_reply_link($args = array(), $post = null);


  • $args (array) – Optional. Override default options. Default: array()
  • $post (int|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: post_reply_link


Basic usage of post_reply_link

Display a simple reply link for the current post.

// Display a basic reply link for the current post

Change the reply link text to “Respond to this post”.

// Set custom reply link text
$args = array(
    'reply_text' => 'Respond to this post'


Display the reply link only for logged-in users.

// Display reply link only for logged-in users
$args = array(
    'logged_in_as' => '<div class="must-log-in">Please log in to reply.</div>'


Add a custom CSS class to the reply link.

// Add custom CSS class to the reply link
$args = array(
    'class' => 'my-custom-reply-link'


Specify a different post for the reply link

Display a reply link for a specific post with ID 42.

// Set the post ID for the reply link
$post_id = 42;

post_reply_link(array(), $post_id);