The post_reply_link() WordPress PHP function displays the HTML content for a reply to post link.
Usage
post_reply_link($args = array(), $post = null);
Parameters
- $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
Examples
Basic usage of post_reply_link
Display a simple reply link for the current post.
// Display a basic reply link for the current post post_reply_link();
Customize the reply link text
Change the reply link text to “Respond to this post”.
// Set custom reply link text $args = array( 'reply_text' => 'Respond to this post' ); post_reply_link($args);
Show reply link only to logged in users
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>' ); post_reply_link($args);
Change the reply link class
Add a custom CSS class to the reply link.
// Add custom CSS class to the reply link $args = array( 'class' => 'my-custom-reply-link' ); post_reply_link($args);
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);