comment_form_title()
Outputs the text for the comment form title, considering whether the commentator is replying to another comment or simply commenting on the post.
Works only if JavaScript is turned off or the script comment-reply.js is not used.
This template tag is typically used immediately after the html tag <div id="respond"> or right before the comment form.
No Hooks.
Returns
null.
Usage
<?php comment_form_title( $noreplytext, $replytext, $linktoparent, $post ); ?>
- $noreplytext(string)
- Text that will be displayed when the commentator is simply commenting on the post.
Default: "leave a comment" - $replytext(string/array/int/object/boolean)
- Text when the commentator is replying to another comment.
Default: "Reply to comment %s" - $linktoparent(boolean)
- Make the commentator's name in the $replytext parameter (
%s) a link to the comment (true) or show it as plain text (false).
Default: true - $post(int|WP_Post|null)
- The post for which the comment form is displayed.
By default, this is the current global post (global $post).
Default: null
Examples
#1 Create a header for the comment form and "wrap" it in the H3 tag:
<h3><?php comment_form_title(); ?></h3>
#2 Display our own texts, different from the default ones:
<h3><?php comment_form_title( 'Comment', 'Reply to commenter: %s' ); ?></h3>
Notes
- Global. WP_Comment. $comment Global comment object.
Changelog
| Since 2.7.0 | Introduced. |
| Since 6.2.0 | Added the $post parameter. |