I am trying to remove the "Click here to cancel reply" link from the Wordpress comment form on my posts. In the document there is an argument you can supply to the comment form function to remove the link, but it doesn't appear to be working. The documentation link: http://codex.wordpress.org/Function_Reference/comment_form

I have tried different values for the cancel_reply_link value including double quotes, double quotes with a space between them, a zero and a value of false; all of which were to no avail. Surely I am overlooking something here as removing that link is pretty common in Wordpress installations.

Here is the current function call with parameters that I am using at present:

<?php comment_form(

    'comment_notes_before' => FALSE,
    'comment_notes_after'  => FALSE,
    'cancel_reply_link'    => FALSE

); ?>

Your help is gratefully appreciated.

2 Answers 2

add_filter( 'cancel_comment_reply_link', '__return_false' );

See /wp-includes/comment-template.php#function get_cancel_comment_reply_link() for more background.

But if you do that the reply form will not move to the comment. The more interesting question is: Why doesn’t the link work for you? Do you have this line in your footer?

is_singular() and get_option( 'thread_comments' ) and wp_print_scripts( 'comment-reply' );
  • Good snippet for filter, I should remember to use those __ returns more often (I use some wrappers around filters in my code so usually stick with and less used to native). As for why it fails - see my answer. Passing empty() stuff around often yields unexpected results in WP.
    – Rarst
    Commented Feb 8, 2011 at 7:28

When you pass false to that argument get_cancel_comment_reply_link() function that is used down the chain falls back to default value.

Pass something else (like single space) or filter cancel_comment_reply_link hook to override output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.