comment_form_title() WordPress Function

This function outputs the title for the comment form.

comment_form_title( string|false $no_reply_text = false, string|false $reply_text = false, bool $link_to_parent = true ) #

Displays text based on comment reply status.


Description

Only affects users with JavaScript disabled.


Top ↑

Parameters

$no_reply_text

(string|false)(Optional) Text to display when not replying to a comment.

Default value: false

$reply_text

(string|false)(Optional) Text to display when replying to a comment. Accepts "%s" for the author of the comment being replied to.

Default value: false

$link_to_parent

(bool)(Optional) Boolean to control making the author's name a link to their comment.

Default value: true


Top ↑

More Information

  • This function affects users with Javascript disabled or pages without the comment-reply.js JavaScript loaded.
  • This function is normally used directly below <div id="respond"> and before the comment form.

Top ↑

Source

File: wp-includes/comment-template.php

function comment_form_title( $no_reply_text = false, $reply_text = false, $link_to_parent = true ) {
	global $comment;

	if ( false === $no_reply_text ) {
		$no_reply_text = __( 'Leave a Reply' );
	}

	if ( false === $reply_text ) {
		/* translators: %s: Author of the comment being replied to. */
		$reply_text = __( 'Leave a Reply to %s' );
	}

	$reply_to_id = isset( $_GET['replytocom'] ) ? (int) $_GET['replytocom'] : 0;

	if ( 0 == $reply_to_id ) {
		echo $no_reply_text;
	} else {
		// Sets the global so that template tags can be used in the comment form.
		$comment = get_comment( $reply_to_id );

		if ( $link_to_parent ) {
			$author = '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author( $comment ) . '</a>';
		} else {
			$author = get_comment_author( $comment );
		}

		printf( $reply_text, $author );
	}
}


Top ↑

Changelog

Changelog
VersionDescription
2.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More