cancel_comment_reply_link()WP 2.7.0

Outputs a link for the comment form: "cancel reply".

Template tag. Used for threaded comments to cancel the reply to the specified comment and return the comment form to its previous position.

No Hooks.

Returns

null. Nothing. Outputs HTML code to the screen.

Usage

<?php cancel_comment_reply_link( $text ); ?>
$text(string)
Text that will become the link text.
Default: 'cancel reply'

Examples

0

#1 Display a link that cancels the response to a certain comment:

<?php cancel_comment_reply_link(); ?>

Using Custom Text

<?php cancel_comment_reply_link( __( 'Cancel Reply', 'textdomain' ) ); ?>
0

#2 Change the html code of the link to cancel the response to a comment

To do this, use the cancel_comment_reply_link hook:

add_filter( 'cancel_comment_reply_link', 'cancel_comment_reply_link_html', 10, 3 );

function cancel_comment_reply_link_html( $formatted_link, $link, $text ){
	return '<span id="cancel-comment-reply-link" style="display:none;">'. $text .'</span>';
}

Changelog

Since 2.7.0 Introduced.

cancel_comment_reply_link() code WP 6.8.1

function cancel_comment_reply_link( $link_text = '' ) {
	echo get_cancel_comment_reply_link( $link_text );
}